From 0d35dfd58ab077e029dd0af30cddf7712c8014a8 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Thu, 14 Aug 2008 19:07:34 +0000 Subject: [PATCH] Don't require c:type. Test boxed.gir Update, remove parts we don't support 2008-08-14 Johan Dahlin * girepository/girparser.c (start_type): Don't require c:type. * tests/Makefile.am: Test boxed.gir * tests/boxed.gir: Update, remove parts we don't support yet * tests/roundtrips.sh: Remove * tools/generate.c (write_type_info), (write_field_info), (write_callable_info), (write_struct_info): Make it emit proper gir. svn path=/trunk/; revision=376 --- ChangeLog | 14 ++++ girepository/girparser.c | 4 - tests/Makefile.am | 12 ++- tests/boxed.gir | 50 +++++------- tests/roundtrips.sh | 28 ------- tools/generate.c | 197 +++++++++++++++++++++++++---------------------- 6 files changed, 146 insertions(+), 159 deletions(-) delete mode 100755 tests/roundtrips.sh diff --git a/ChangeLog b/ChangeLog index 355f9f5..b056ec6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2008-08-14 Johan Dahlin + * girepository/girparser.c (start_type): + Don't require c:type. + * tests/Makefile.am: + Test boxed.gir + * tests/boxed.gir: + Update, remove parts we don't support yet + * tests/roundtrips.sh: + Remove + * tools/generate.c (write_type_info), (write_field_info), + (write_callable_info), (write_struct_info): + Make it emit proper gir. + +2008-08-14 Johan Dahlin + * giscanner/transformer.py: New internal function for adding a new node. diff --git a/girepository/girparser.c b/girepository/girparser.c index dfc7042..6b7942e 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -1342,7 +1342,6 @@ start_type (GMarkupParseContext *context, GError **error) { const gchar *name; - const gchar *ctype; if (strcmp (element_name, "type") != 0 || !(ctx->state == STATE_FUNCTION_PARAMETER || @@ -1366,12 +1365,9 @@ start_type (GMarkupParseContext *context, } name = find_attribute ("name", attribute_names, attribute_values); - ctype = find_attribute ("c:type", attribute_names, attribute_values); if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); - if (ctype == NULL) - MISSING_ATTRIBUTE (context, error, element_name, "c:type"); switch (ctx->current_typed->type) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 5ddcc52..479a30a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,6 @@ SUBDIRS = . invoke scanner EXTRA_DIST = \ - roundtrips.sh \ array.gir \ boxed.gir \ constant.gir \ @@ -17,9 +16,16 @@ EXTRA_DIST = \ xref1.gir \ xref2.gir -TESTS = #roundtrips.sh +GIRTESTS = \ + boxed.gir.test -check-local: +%.gir.test: %.gir + @echo Testing $<: + $(top_builddir)/tools/g-ir-compiler --raw $< > $<.1; \ + $(top_builddir)/tools/g-ir-generate --raw $<.1 > $<.2; \ + diff -u $< $<.2; rm $<.1 $<.2 + +check-local: $(GIRTESTS) @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/boxed.gir b/tests/boxed.gir index fb1b18c..bf9278c 100644 --- a/tests/boxed.gir +++ b/tests/boxed.gir @@ -6,71 +6,57 @@ - + - + - + - - + - - + + - - - - + + - - - + - + - + - - + + - + - - + + - + - + diff --git a/tests/roundtrips.sh b/tests/roundtrips.sh deleted file mode 100755 index b7936b5..0000000 --- a/tests/roundtrips.sh +++ /dev/null @@ -1,28 +0,0 @@ -#! /bin/sh - -set -x -set -e - -TESTFILES=$(echo *.gir) - -for i in $TESTFILES; do - ${CHECK_DEBUG} ../tools/g-ir-compiler --raw $i > $i.1; - ${CHECK_DEBUG} ../tools/g-ir-generate --raw $i.1 > $i.2; - diff -u $srcdir/$i $i.2 || exit 1; - rm $i.1 $i.2 -done - -#../tools/g-ir-compiler --raw --module=Foo $srcdir/object.test $srcdir/gobject.test > object.test.1 -#../tools/g-ir-generate --raw object.test.1 > object.test.2 -#diff -u $srcdir/object.test object.test.2 || exit 1 -#rm object.test.1 object.test.2 - -#../tools/g-ir-compiler --raw --module=Foo $srcdir/xref1.test $srcdir/xref2.test > xref1.test.1 -#../tools/g-ir-generate --raw xref1.test.1 > xref1.test.2 -#diff -u $srcdir/xref1.test xref1.test.2 || exit 1 -#rm xref1.test.1 xref1.test.2 - -#../tools/g-ir-compiler --raw --module=Bar $srcdir/xref1.test $srcdir/xref2.test > xref2.test.1 -#../tools/g-ir-generate --raw xref2.test.1 > xref2.test.2 -#diff -u $srcdir/xref2.test xref2.test.2 || exit 1 -#rm xref2.test.1 xref2.test.2 diff --git a/tools/generate.c b/tools/generate.c index f3acc9c..1292c3d 100644 --- a/tools/generate.c +++ b/tools/generate.c @@ -54,24 +54,24 @@ write_type_info (const gchar *namespace, GITypeInfo *type; const gchar* basic[] = { - "void", - "gboolean", - "gint8", - "guint8", - "gint16", - "guint16", - "gint32", - "guint32", - "gint64", - "guint64", - "gint", - "guint", - "glong", - "gulong", - "gssize", - "gsize", - "gfloat", - "gdouble", + "none", + "boolean", + "int8", + "uint8", + "int16", + "uint16", + "int32", + "uint32", + "int64", + "uint64", + "int", + "uint", + "long", + "ulong", + "ssize", + "size", + "float", + "double", "utf8", "filename" }; @@ -200,21 +200,16 @@ write_field_info (const gchar *namespace, offset = g_field_info_get_offset (info); g_fprintf (file, - " \n"); + g_fprintf (file,">\n"); + + g_fprintf (file, " \n"); + + g_fprintf (file, " \n"); + } static void @@ -237,12 +242,9 @@ write_callable_info (const gchar *namespace, GITypeInfo *type; gint i; - g_fprintf (file, "%*s \n", indent, ""); type = g_callable_info_get_return_type (info); - write_type_info (namespace, type, file); - - g_fprintf (file, "\""); if (g_type_info_is_pointer (type)) { @@ -265,75 +267,86 @@ write_callable_info (const gchar *namespace, if (g_callable_info_may_return_null (info)) g_fprintf (file, " null-ok=\"1\""); - g_fprintf (file, " />\n"); + g_fprintf (file, "%*s \n"); + + g_fprintf (file, "%*s \n", indent, ""); - if (g_callable_info_get_n_args (info) > 0) + if (g_callable_info_get_n_args (info) <= 0) + return; + + g_fprintf (file, "%*s \n", indent, ""); + for (i = 0; i < g_callable_info_get_n_args (info); i++) { - g_fprintf (file, "%*s \n", indent, ""); - for (i = 0; i < g_callable_info_get_n_args (info); i++) + GIArgInfo *arg = g_callable_info_get_arg (info, i); + + g_fprintf (file, "%*s \n"); - - g_base_info_unref ((GIBaseInfo *)arg); + } + g_base_info_unref ((GIBaseInfo *)type); + + g_fprintf (file, " direction=\""); + switch (g_arg_info_get_direction (arg)) + { + case GI_DIRECTION_IN: + g_fprintf (file, "in"); + break; + case GI_DIRECTION_OUT: + g_fprintf (file, "out"); + break; + case GI_DIRECTION_INOUT: + g_fprintf (file, "inout"); + break; } - - g_fprintf (file, "%*s \n", indent, ""); + g_fprintf (file, "\""); + + if (g_arg_info_may_be_null (arg)) + g_fprintf (file, " null-ok=\"1\""); + + if (g_arg_info_is_dipper (arg)) + g_fprintf (file, " dipper=\"1\""); + + if (g_arg_info_is_return_value (arg)) + g_fprintf (file, " retval=\"1\""); + + if (g_arg_info_is_optional (arg)) + g_fprintf (file, " optional=\"1\""); + + g_fprintf (file, ">\n"); + + g_fprintf (file, "%*s \n"); + + g_fprintf (file, "%*s \n", indent, ""); + + g_base_info_unref ((GIBaseInfo *)arg); } + + g_fprintf (file, "%*s \n", indent, ""); } static void @@ -417,7 +430,7 @@ write_struct_info (const gchar *namespace, type_name = g_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info); type_init = g_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info); - g_fprintf (file, " \n"); + g_fprintf (file, " \n"); else g_fprintf (file, " \n"); } -- 2.7.4