Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters <walters@src.gnome.org>2009-02-11 00:08:49 (GMT)
committer Colin Walters <walters@src.gnome.org>2009-02-11 00:08:49 (GMT)
commite8fe46415ee058af96ca93f822e0ded9b033f45a (patch)
treee5bcb57c76d92f995169d01f21dfe688343177be
parent049dc259e7f2c5f71eec63fb42a5cd5ec70d7be3 (diff)
Bug 571248 - Ignore unknown elements in girparser
We want the gir to be extensible. svn path=/trunk/; revision=1096
-rw-r--r--girepository/girparser.c27
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/extended.gir17
3 files changed, 40 insertions, 12 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c
index b376234..97e3a1e 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -66,7 +66,8 @@ typedef enum
STATE_CLASS_CONSTANT,
STATE_INTERFACE_CONSTANT,
STATE_ALIAS,
- STATE_TYPE
+ STATE_TYPE,
+ STATE_UNKNOWN
} ParseState;
typedef struct _ParseContext ParseContext;
@@ -75,6 +76,7 @@ struct _ParseContext
GIrParser *parser;
ParseState state;
+ int unknown_depth;
ParseState prev_state;
GList *modules;
@@ -2640,15 +2642,15 @@ start_element_handler (GMarkupParseContext *context,
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_element_handler (GMarkupParseContext *context,
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);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d77e493..3da1c30 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,6 +6,7 @@ EXTRA_DIST = \
constant.gir \
enum.gir \
errors.gir \
+ extended.gir \
function.gir \
interface.gir \
object.gir \
@@ -22,7 +23,10 @@ GIRTESTS = \
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 @@ CLEANFILES = $(GIRTESTS:%.gir.test=%.1) $(GIRTESTS:%.gir.test=%.2)
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
diff --git a/tests/extended.gir b/tests/extended.gir
new file mode 100644
index 0000000..fadb486
--- /dev/null
+++ b/tests/extended.gir
@@ -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>