summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-06-17 10:38:39 -0400
committerColin Walters <walters@verbum.org>2010-06-17 10:49:41 -0400
commit7b4af5e3bd9081e5ff72d9439bb868017dd8c2c8 (patch)
treeb24d72c5d8bf36c5e8fd20d666fe6da657401774
parentb683ef027b2d96c7cd6c7f895a0437a03567dc05 (diff)
downloadgobject-introspection-7b4af5e3bd9081e5ff72d9439bb868017dd8c2c8.tar.gz
More explicitly document how we'll use the version= attribute on repository
I want to start bumping it on incompatible .gir changes. https://bugzilla.gnome.org/show_bug.cgi?id=621895
-rw-r--r--girepository/girparser.c7
-rw-r--r--giscanner/girparser.py7
-rw-r--r--giscanner/girwriter.py5
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'),