diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-11-16 17:26:24 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-11-17 10:14:08 +0000 |
commit | cd0be1aa95b41cc66f6a5bf4f95733fa91fa8dc9 (patch) | |
tree | f50e4b13c8ae379835a66ecedb3ba7907600df30 | |
parent | cfba7302281f1fbb39a0c5864bcc038bab2ed55b (diff) | |
download | telepathy-glib-cd0be1aa95b41cc66f6a5bf4f95733fa91fa8dc9.tar.gz |
gobject-foo.py: generate interface boilerplate correctly
In the test, use the interface-names-are-adjectives pattern, and update
the expected output.
Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r-- | tests/tools/expected-ginterface-foo.h | 27 | ||||
-rw-r--r-- | tests/tools/test-gobject-foo.sh | 2 | ||||
-rw-r--r-- | tools/gobject-foo.py | 23 |
3 files changed, 30 insertions, 22 deletions
diff --git a/tests/tools/expected-ginterface-foo.h b/tests/tools/expected-ginterface-foo.h index 03761b229..6aa4920fa 100644 --- a/tests/tools/expected-ginterface-foo.h +++ b/tests/tools/expected-ginterface-foo.h @@ -1,16 +1,15 @@ -typedef struct _XyzBadgerMushroomSnake XyzBadgerMushroomSnake; -typedef struct _XyzBadgerMushroomSnakeClass XyzBadgerMushroomSnakeClass; -typedef struct _XyzBadgerMushroomSnakePrivate XyzBadgerMushroomSnakePrivate; +typedef struct _XyzBadgerIrritable XyzBadgerIrritable; +typedef struct _XyzBadgerIrritableInterface XyzBadgerIrritableInterface; -GType xyz_badger_mushroom_snake_get_type (void); +GType xyz_badger_irritable_get_type (void); -#define XYZ_BADGER_TYPE_MUSHROOM_SNAKE \ - (xyz_badger_mushroom_snake_get_type ()) -#define XYZ_BADGER_MUSHROOM_SNAKE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), XYZ_BADGER_TYPE_MUSHROOM_SNAKE, \ - XyzBadgerMushroomSnake)) -#define XYZ_BADGER_IS_MUSHROOM_SNAKE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XYZ_BADGER_TYPE_MUSHROOM_SNAKE)) -#define XYZ_BADGER_MUSHROOM_SNAKE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), XYZ_BADGER_TYPE_MUSHROOM_SNAKE, \ - XyzBadgerMushroomSnakeClass)) +#define XYZ_BADGER_TYPE_IRRITABLE \ + (xyz_badger_irritable_get_type ()) +#define XYZ_BADGER_IRRITABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), XYZ_BADGER_TYPE_IRRITABLE, \ + XyzBadgerIrritable)) +#define XYZ_BADGER_IS_IRRITABLE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XYZ_BADGER_TYPE_IRRITABLE)) +#define XYZ_BADGER_IRRITABLE_GET_IFACE(obj) \ + (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XYZ_BADGER_TYPE_IRRITABLE, \ + XyzBadgerIrritableInterface)) diff --git a/tests/tools/test-gobject-foo.sh b/tests/tools/test-gobject-foo.sh index 465678102..6bce48c65 100644 --- a/tests/tools/test-gobject-foo.sh +++ b/tests/tools/test-gobject-foo.sh @@ -5,7 +5,7 @@ set -e ${PYTHON} ${top_srcdir}/tools/gobject-foo.py Xyz_Badger Mushroom_Snake \ > gobject-foo.h ${PYTHON} ${top_srcdir}/tools/gobject-foo.py --interface \ - Xyz_Badger Mushroom_Snake > ginterface-foo.h + Xyz_Badger Irritable > ginterface-foo.h e=0 # We assume POSIX diff, until someone complains diff --git a/tools/gobject-foo.py b/tools/gobject-foo.py index 5921cab8a..002a290ba 100644 --- a/tools/gobject-foo.py +++ b/tools/gobject-foo.py @@ -5,7 +5,7 @@ # The master copy of this program is in the telepathy-glib repository - # please make any changes there. # -# Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/> +# Copyright (C) 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -33,8 +33,13 @@ def gobject_header(head, tail, as_interface=False): gtype = head.upper() + '_TYPE_' + tail.upper() o("typedef struct _%s %s;" % (MixedCase, MixedCase)) - o("typedef struct _%sClass %sClass;" % (MixedCase, MixedCase)) - o("typedef struct _%sPrivate %sPrivate;" % (MixedCase, MixedCase)) + + if as_interface: + o("typedef struct _%sInterface %sInterface;" % (MixedCase, MixedCase)) + else: + o("typedef struct _%sClass %sClass;" % (MixedCase, MixedCase)) + o("typedef struct _%sPrivate %sPrivate;" % (MixedCase, MixedCase)) + o("") o("GType %s_get_type (void);" % lower_case) o("") @@ -54,13 +59,17 @@ def gobject_header(head, tail, as_interface=False): o("#define %s_IS_%s(obj) \\" % (head.upper(), tail.upper())) o(" (G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))" % gtype) - if not as_interface: + if as_interface: + o("#define %s_GET_IFACE(obj) \\" % UPPER_CASE) + o(" (G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, \\" % gtype) + o(" %sInterface))" % MixedCase) + else: o("#define %s_IS_%s_CLASS(klass) \\" % (head.upper(), tail.upper())) o(" (G_TYPE_CHECK_CLASS_TYPE ((klass), %s))" % gtype) - o("#define %s_GET_CLASS(obj) \\" % UPPER_CASE) - o(" (G_TYPE_INSTANCE_GET_CLASS ((obj), %s, \\" % gtype) - o(" %sClass))" % MixedCase) + o("#define %s_GET_CLASS(obj) \\" % UPPER_CASE) + o(" (G_TYPE_INSTANCE_GET_CLASS ((obj), %s, \\" % gtype) + o(" %sClass))" % MixedCase) return out |