[gobject-introspection] More explicitly document how we'll use the version= attribute on repository



commit 7b4af5e3bd9081e5ff72d9439bb868017dd8c2c8
Author: Colin Walters <walters verbum org>
Date:   Thu Jun 17 10:38:39 2010 -0400

    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

 girepository/girparser.c |    7 ++++++-
 giscanner/girparser.py   |    7 +++++++
 giscanner/girwriter.py   |    5 ++++-
 3 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/girepository/girparser.c b/girepository/girparser.c
index d0bd8aa..f9c1fb6 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 852874d..57db0fb 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 2dff4fe..11f9dbe 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'),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]