diff options
-rw-r--r-- | girepository/girparser.c | 7 | ||||
-rw-r--r-- | giscanner/girparser.py | 7 | ||||
-rw-r--r-- | giscanner/girwriter.py | 5 |
3 files changed, 17 insertions, 2 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c index d0bd8aa3..f9c1fb66 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -30,6 +30,11 @@ #include "gitypelib-internal.h" #include "config.h" +/* This is a "major" version in the sense that it's only bumped + * for incompatible changes. + */ +#define SUPPORTED_GIR_VERSION "1.0" + #if defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS) # include <execinfo.h> #endif @@ -2754,7 +2759,7 @@ start_element_handler (GMarkupParseContext *context, if (version == NULL) MISSING_ATTRIBUTE (context, error, element_name, "version"); - else if (strcmp (version, "1.0") != 0) + else if (strcmp (version, SUPPORTED_GIR_VERSION) != 0) g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 852874d9..57db0fb6 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -27,6 +27,8 @@ from .glibast import (GLibEnum, GLibEnumMember, GLibFlags, GLibInterface, GLibObject, GLibBoxedStruct, GLibBoxedUnion, GLibBoxedOther) +from .girwriter import COMPATIBLE_GIR_VERSION + CORE_NS = "http://www.gtk.org/introspection/core/1.0" C_NS = "http://www.gtk.org/introspection/c/1.0" GLIB_NS = "http://www.gtk.org/introspection/glib/1.0" @@ -93,6 +95,11 @@ class GIRParser(object): def _parse_api(self, root): assert root.tag == _corens('repository') + version = root.attrib['version'] + if version != COMPATIBLE_GIR_VERSION: + raise ValueError("Incompatible version %s (supported: %s)", + version, COMPATIBLE_GIR_VERSION) + for node in root.getchildren(): if node.tag == _corens('include'): self._parse_include(node) diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 2dff4fe2..11f9dbe9 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -29,6 +29,9 @@ from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibRecord) from .xmlwriter import XMLWriter +# Bump this for *incompatible* changes to the .gir. +# Compatible changes we just make inline +COMPATIBLE_GIR_VERSION = '1.0' class GIRWriter(XMLWriter): @@ -50,7 +53,7 @@ and/or use gtk-doc annotations. ''') if c_includes is None: c_includes = frozenset() attrs = [ - ('version', '1.0'), + ('version', COMPATIBLE_GIR_VERSION), ('xmlns', 'http://www.gtk.org/introspection/core/1.0'), ('xmlns:c', 'http://www.gtk.org/introspection/c/1.0'), ('xmlns:glib', 'http://www.gtk.org/introspection/glib/1.0'), |