summaryrefslogtreecommitdiff
path: root/giscanner/girwriter.py
Commit message (Collapse)AuthorAgeFilesLines
* scanner: parse and expose function macrosMathieu Duponchelle2019-07-191-0/+25
| | | | | This is useful for documentation tools, and other utilities that rely on full introspection of the C API of a given library.
* Drop all Python 2 compat codeChristoph Reiter2018-12-081-6/+0
| | | | We only support 3.4+ now.
* giscanner/girwriter.py: Fix running on WindowsChun-wei Fan2018-12-061-1/+8
| | | | | | | ... When we are building in a drive that is different from the drive that we are acquiring the depedencies from. For example, os.path.relpath() does not like it when we we are building G-I on D:\foo while the GLib headers are found are C:\glib.
* writer: Include documentation and symbol position in source filesThibault Saunier2018-11-281-3/+28
| | | | | | | | | | | 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
* typedefs: fix type information.Mathieu Duponchelle2017-03-141-1/+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: Mark gpointer nodes as nullable by defaultPhilip Withnall2015-10-041-2/+2
| | | | | | | | | | | | | 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: Use rich comparison methods for Python 3 compatibilitySimon Feltman2015-09-291-10/+5
| | | | | | | | | | 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
* giscanner: Use unicode literals in all Python filesSimon Feltman2015-09-291-0/+1
| | | | | | | | | | | | 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: 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/+1
| | | | | | 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-1/+1
| | | | | | | Replace usage of iteritems() and itervalues() with items() and values() respectively. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: support nullable return types tooRyan Lortie2014-05-061-0/+2
| | | | | | | | | | Promote the 'nullable' field to the TypeContainer base class (which is shared by Return and Parameter types). Add .gir support for nullability on return values, both in the writer and in the (scanner's) parser. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: write nullable and optional attributesRyan Lortie2014-05-061-0/+2
| | | | | | | | | | | | | | | | | | | Record our internal 'nullable' and 'optional' attributes into the written .gir file. It is now theoretically possible to express the concept of an out parameter with a nullable type (although presently there is no way to do this). Modify our own internal parser (in the scanner) to understand the newly-written attributes. Update the expected output of the 'Regress-1.0.gir' test to account for the new attributes. Nothing else understands 'nullable' yet, but the girparser in the typelib compiler already understands 'optional' and records a bit for it in the typelib. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: change some internal field logicRyan Lortie2014-05-061-2/+6
| | | | | | | | | | | | | | | | | | Replace the 'allow_none' field on parameters with two separate fields: 'nullable' and 'optional'. Currently, we use 'nullable' to mean the same thing as 'allow-none' for normal (non-out) parameters. For out parameters, we use the 'optional' field instead. Note that the special case for GCancellable and GAsyncReadyCallback is already guarded by a check for being an in parameter, so we always use 'nullable' here. On the .gir writer side, we decide which variable to consult when writing the allow-none attribute depending on the parameter direction. https://bugzilla.gnome.org/show_bug.cgi?id=660879
* giscanner: Correctly consume field annotations on structsStef Walter2013-10-281-10/+14
| | | | | | | | A hidden exception was being thrown (which we now log), due to fields being treated as function parameters. Fixed to make field array annotations be transformed and written out to the gir correctly. https://bugzilla.gnome.org/show_bug.cgi?id=710561
* giscanner: remove unneeded isinstance checkDieter Verfaillie2013-10-091-3/+2
| | | | | | _write_class() is only ever called with ast.Class and ast.Interface nodes so the check served no purpose other than contribute to global warming...
* giscanner: write '<varargs/>' instead of '<varargs></varargs>'Dieter Verfaillie2013-10-081-2/+1
|
* giscanner: make Annotated.attributes an OrderedDictDieter Verfaillie2013-10-081-1/+1
| | | | | | annotationparser.py already stores attributes in a mapping so it makes little sense using a list of tuples (suggesting multiple duplicate keys would be allowed) on the ast side.
* giscanner: fix description field storage in .gir filesDieter Verfaillie2013-10-081-4/+23
| | | | | | | | | | | | | | | | | | GTK-Doc description fields for tags can contain multiple lines and even multiple paragraphs. Whitespace cannot be preserved in XML attributes, so we move the "deprecated" description text into a "<doc-deprecated />" element right next to where we already have the "<doc />" element. Keep the "deprecated" attribute around for backwards compatibility though, but set its value to "1" (analogous to the "writable", "contruct", etc attributes) if the annotated symbol is marked as deprecated. While at it, add <doc-version /> and <doc-stability /> which was not yet available in the .gir files... This takes care of the "Since:", "Stability:" and "Deprecated:" GTK-Doc tags. Nothing needs to be done for the "Returns:" tag as as we already write a "<doc />" child element on "<return-value />".
* tests: Update misc/pep8.py to 1.4.5Dieter Verfaillie2013-05-071-11/+10
| | | | | | | | | | | | | | | | | 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
* giscanner: fix broken xml:whitespace attributes in .gir filesDieter Verfaillie2013-04-091-1/+1
| | | | | | | The XML specification clearly states it's xml:space http://www.w3.org/TR/xml/#sec-white-space https://bugzilla.gnome.org/show_bug.cgi?id=628739
* scanner: internals cleanup: Move pkgconfig list to NamespaceColin Walters2013-02-261-6/+4
| | | | Continuation of previous work.
* scanner: internals cleanup: Move c_includes to NamespaceColin Walters2013-02-261-8/+4
| | | | Continuation of previous work.
* scanner: internals cleanup: Move shared libraries to NamespaceColin Walters2013-02-261-6/+6
| | | | Continuing on with previous commit.
* scanner: internals cleanup: Key more things off NamespaceColin Walters2013-02-261-6/+4
| | | | | | | | | | | The .gir format has a weird legacy where stuff like the includes are outside of the <namespace>. But conceptually they're tied together, so let's start reflecting this in the code. This way we can just pass around and look at a Namespace object instead of a 4-tuple of (namespace, includes, c_includes, pkg_config). https://bugzilla.gnome.org/show_bug.cgi?id=694593
* ast: Rename Class.parent to parent_typeJasper St. Pierre2013-02-151-2/+2
| | | | | | | | | The eventual model I want to have is that .parent is the "container" of the node. In all the cases where we don't explicitly set the parent, this is the namespace, but having this under one field name would be a big cleanup for the docwriter. https://bugzilla.gnome.org/show_bug.cgi?id=693876
* scanner: remove backcompat copies more safelyTorsten Schönfeld2013-02-101-0/+2
| | | | | | | | Instead of modifying the namespace while we are iterating over it, which leads to nodes not being tested, set an 'internal_skipped' property on the function and read it in the GIR writer. https://bugzilla.gnome.org/show_bug.cgi?id=660698
* girparser: Serialize and read back the instance_parameterJasper St. Pierre2013-02-011-8/+10
| | | | | | | | g-ir-doc-tool wants to use the instance parameter to read docs and the parameter name, so it needs to be shuttled through the GIR. https://bugzilla.gnome.org/show_bug.cgi?id=693040
* giscanner: Apply standard annotations to constant valuesJasper St. Pierre2013-02-011-0/+3
| | | | | | | | | | While there's no particular reason I need to do this, there really isn't any reason to not do this, and it helps with doctool or whatever in the future if we want to document when a constant showed up. g-ir-compiler also keeps track of constant deprecations, so this fixes constants not ever being deprecated. https://bugzilla.gnome.org/show_bug.cgi?id=693040
* Add documentation for enumeration membersGiovanni Campagna2012-10-281-1/+2
| | | | | | | | Enum members were Annotated in the AST, and most code already assumed they could have docs. What was missing was reading the docs from the comment blocks and writing them in the XML. https://bugzilla.gnome.org/show_bug.cgi?id=683046
* mallardwriter: Fix formatting the function nameJasper St. Pierre2012-08-291-2/+2
| | | | This is not what format_type is for.
* scanner: support stability tagEvan Nemerson2012-07-101-0/+2
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=679160
* giscanner: Write detailed information in "type" tag's "c:type" attribute.Krzesimir Nowak2012-07-071-1/+3
| | | | | | | | That is - write also type qualifiers (const and volatile here). Update existing tests and add a new struct to regress.h having members with type qualifiers. https://bugzilla.gnome.org/show_bug.cgi?id=656445
* Add constant value annotationJohan Dahlin2011-09-141-1/+3
| | | | | Add an annotation tag "Value:" which can be used on constants to override the value.
* Allow enums and bitfields to have static methodsTorsten Schönfeld2011-08-161-0/+4
| | | | | | | | | | | | | This uses the same backcompat machinery that was introduced for static methods for non-class types, so this change does not break users of the existing presentations. New libgirepository API: g_enum_info_get_n_methods g_enum_info_get_method https://bugzilla.gnome.org/show_bug.cgi?id=656499
* Make sure signal works when there isn't one specifiedJohan Dahlin2011-08-131-2/+3
|
* Add signal flagsJohan Dahlin2011-08-131-1/+11
| | | | | | This adds all GSignalFlags into the gir. https://bugzilla.gnome.org/show_bug.cgi?id=656457
* scanner: add a moved_to property to backcompat functionsTorsten Schönfeld2011-08-131-0/+2
| | | | | | | Use it to remove backcompat copies of functions that non introspectable anyway. https://bugzilla.gnome.org/show_bug.cgi?id=572408
* scanner: Don't throw away blank lines in the docsColin Walters2011-08-131-1/+1
| | | | | | For generating documentation, we actually want to preserve these. https://bugzilla.gnome.org/show_bug.cgi?id=656389
* Switch to storing string form of error quarksDan Winship2011-08-121-2/+2
| | | | | | | | | | | | | | | | Instead of storing the name of the function to call to get the error quark, store the string form of the error quark, which we derive from the introspection binary during scanning. Update EnumBlob and GIEnumInfo to include the new information. This will allow determining a back-mapping from error quark to error domain without having to dlsym() and call all the known error quark functions. Based on earlier patches from Owen Taylor and Maxim Ermilov. https://bugzilla.gnome.org/show_bug.cgi?id=602516
* Always add a zero-terminated attribute when it cannot be impliedGiovanni Campagna2011-06-041-0/+6
| | | | | | | | | | | | g-ir-compiler assumes that an array is zero terminated when the attribute is absent and there is no other attribute (length and fixed-size), but g-ir-scanner only added the attribute when it is 0. This means that an explicit zero-terminated=1 annotation would have had no effect. Fix that and at the same time ensure that all other arrays are not zero-terminated by default. https://bugzilla.gnome.org/show_bug.cgi?id=646635
* Add support for the (skip) annotation on parameters or return valuesDavid Zeuthen2011-05-131-0/+4
| | | | | | | | This was discussed in bug 649657. https://bugzilla.gnome.org/show_bug.cgi?id=649657 Signed-off-by: David Zeuthen <davidz@redhat.com>
* make check pass for recent commitsColin Walters2010-12-171-1/+1
| | | | | * Fix use of tabs * Update for correct signal parameters
* scanner: support typedefs for container typesJonathan Matthew2010-12-161-1/+23
| | | | | | | | | | | Inside an alias definition, we only need the name of the alias target type. Add a method to GIRWriter to write out a type reference rather than full type definition and use it when writing out an alias. Determine introspectableness of aliases in IntrospectablePass so functions using aliases can be marked not-introspectable if the alias itself is not. https://bugzilla.gnome.org/show_bug.cgi?id=629682
* [scanner] Support private/public directivesJohan Dahlin2010-09-201-0/+2
| | | | Fixes https://bugzilla.gnome.org/show_bug.cgi?id=594125
* scanner: Add c_type for callbacksColin Walters2010-09-141-1/+1
| | | | | | | We weren't doing this consistently, which broke nsname != cprefix cases. https://bugzilla.gnome.org/show_bug.cgi?id=629683
* scanner: Parse annotations for typedefsColin Walters2010-09-141-0/+2
| | | | | | | | * Explicitly check for ast.Alias in annotation pass * Add "generic" attribs handling for aliases like docs, introspectable=0 etc. https://bugzilla.gnome.org/show_bug.cgi?id=629668
* scanner: Kill glibastColin Walters2010-09-081-77/+67
| | | | | | | | | | | | It was a stupid abstraction split, we only support GObject. * Clean up how we handle c:type - we only set it if we've actually seen a corresponding structure. * Add a warning if we don't see the structure typedef for an interface, since that's pretty bogus. (And fix regress.h to have one) * Rename the "type_name" attribute internally to "gtype_name" for clarity.
* Go back to previously handling of static methods on non-GObjectsOwen W. Taylor2010-09-071-0/+1
| | | | | | | | | | | | | Previous to the scanner rewrite, static methods were only handled for GObject subclasses. Go back to that for full compatibility with existing bindings and code. See bug 572408 for the topic of changing the API. The code for writing out static methods for records and boxed is left as future proofing, and the same handling is added for interfaces. https://bugzilla.gnome.org/show_bug.cgi?id=628967