gobject-introspection r1096 - in trunk: girepository tests



Author: walters
Date: Wed Feb 11 00:08:49 2009
New Revision: 1096
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=1096&view=rev

Log:
Bug 571248 - Ignore unknown elements in girparser

We want the gir to be extensible.

Added:
   trunk/tests/extended.gir
Modified:
   trunk/girepository/girparser.c
   trunk/tests/Makefile.am

Modified: trunk/girepository/girparser.c
==============================================================================
--- trunk/girepository/girparser.c	(original)
+++ trunk/girepository/girparser.c	Wed Feb 11 00:08:49 2009
@@ -66,7 +66,8 @@
   STATE_CLASS_CONSTANT, 
   STATE_INTERFACE_CONSTANT,
   STATE_ALIAS,
-  STATE_TYPE
+  STATE_TYPE,
+  STATE_UNKNOWN
 } ParseState;
 
 typedef struct _ParseContext ParseContext;
@@ -75,6 +76,7 @@
   GIrParser *parser;
 
   ParseState state;
+  int unknown_depth;
   ParseState prev_state;
 
   GList *modules;
@@ -2640,15 +2642,15 @@
       break;
     }
 
-  g_markup_parse_context_get_position (context, &line_number, &char_number);
-
-  if (error && *error == NULL)
-    g_set_error (error,
-		 G_MARKUP_ERROR,
-		 G_MARKUP_ERROR_UNKNOWN_ELEMENT,
-		 "Unexpected start tag '%s' on line %d char %d; current state=%d",
-		 element_name,
-		 line_number, char_number, ctx->state);
+  if (ctx->state != STATE_UNKNOWN)
+    {
+      state_switch (ctx, STATE_UNKNOWN);
+      ctx->unknown_depth = 1;
+    }
+  else
+    {
+      ctx->unknown_depth += 1;
+    }
   
  out: ;
   if (*error) 
@@ -3008,6 +3010,11 @@
 	  end_type (ctx);
 	  break;
 	}
+    case STATE_UNKNOWN:
+      ctx->unknown_depth -= 1;
+      if (ctx->unknown_depth == 0)
+        state_switch (ctx, ctx->prev_state);
+      break;
     default:
       g_error ("Unhandled state %d in end_element_handler\n", ctx->state);
     }

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	(original)
+++ trunk/tests/Makefile.am	Wed Feb 11 00:08:49 2009
@@ -6,6 +6,7 @@
 	constant.gir	\
 	enum.gir	\
 	errors.gir	\
+	extended.gir \
 	function.gir	\
 	interface.gir	\
 	object.gir	\
@@ -22,7 +23,10 @@
 	object.gir.test		\
 	struct.gir.test
 
-CLEANFILES = $(GIRTESTS:%.gir.test=%.1) $(GIRTESTS:%.gir.test=%.2)
+CLEANFILES = $(GIRTESTS:%.gir.test=%.1) $(GIRTESTS:%.gir.test=%.2) extended.gir.test
+
+extended.gir.test: extended.gir Makefile
+	$(DEBUG) $(top_builddir)/tools/g-ir-compiler --includedir=$(top_builddir)/gir extended.gir -o extended.gir.test
 
 %.gir.test: %.gir Makefile
 	@echo Testing $<:
@@ -31,7 +35,7 @@
 	diff -u $(srcdir)/$*.gir $*.2 && rm $*.1 $*.2
 
 
-check-local: $(GIRTESTS)
+check-local: $(GIRTESTS) extended.gir.test
 	@echo Running PEP8 on Python sources
 	@find $(top_srcdir)/giscanner -name \*.py | sort | uniq | xargs $(PYTHON) $(top_srcdir)/misc/pep8.py --repeat
 	@echo Running Pyflakes on Python sources

Added: trunk/tests/extended.gir
==============================================================================
--- (empty file)
+++ trunk/tests/extended.gir	Wed Feb 11 00:08:49 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<repository version="1.0"
+            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";>
+  <include name="GObject" version="2.0"/>
+  <foofoo></foofoo>
+  <namespace name="extended" version="1.0">
+    <frob>
+      <bar>
+      </bar>
+    </frob>
+    <constant name="KEY_FROB" value="31">
+      <type name="int"/>
+    </constant>
+  </namespace>
+</repository>



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