From 093d9880c4c9b3242ad21dc4379c22196d343daf Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Fri, 15 Feb 2013 15:18:05 +0100 Subject: [PATCH] adg: dropped ADG_TYPEDEF This was a horrible hack to get gtk-doc working. Anyway it messed up the GObject introspection side. Dropped the hack and accessed a private struct in cairo.h (the lesser of two evils). Rearranged code to still work with gtk-doc by using a helper header file disabled only from the gtk-doc side. --- docs/adg/Makefile.am | 13 +++++----- src/adg.h.in | 1 + src/adg/Makefile.am | 1 + src/adg/adg-canvas.h.in | 6 +---- src/adg/adg-dim.c | 2 +- src/adg/adg-dress.h | 6 ----- src/adg/adg-entity.h | 12 ++------- src/adg/adg-forward-declarations.h | 50 ++++++++++++++++++++++++++++++++++++++ src/adg/adg-internal.h | 1 + src/adg/adg-matrix.h | 6 ++--- src/adg/adg-point.h | 5 ---- src/adg/adg-style.h | 4 --- src/adg/adg-table-cell.h | 6 ----- src/adg/adg-table-row.h | 6 ----- src/adg/adg-table.h | 5 ---- src/adg/adg-utils.c | 24 ------------------ src/adg/adg-utils.h | 2 -- 17 files changed, 66 insertions(+), 84 deletions(-) create mode 100644 src/adg/adg-forward-declarations.h diff --git a/docs/adg/Makefile.am b/docs/adg/Makefile.am index 114b2d96..00ba3b11 100644 --- a/docs/adg/Makefile.am +++ b/docs/adg/Makefile.am @@ -16,11 +16,6 @@ FIXXREF_OPTIONS= --extra-dir=$(top_srcdir)/docs/cpml HFILE_GLOB= $(top_srcdir)/src/adg/*.h CFILE_GLOB= $(top_srcdir)/src/adg/*.c IGNORE_HFILES= adg.h \ - adg-internal.h \ - adg-introspection.h \ - adg-text-internal.h \ - adg-type-builtins.h \ - adg-marshal.h \ adg-adim-private.h \ adg-alignment-private.h \ adg-arrow-private.h \ @@ -35,26 +30,32 @@ IGNORE_HFILES= adg.h \ adg-entity-private.h \ adg-fill-style-private.h \ adg-font-style-private.h \ + adg-forward-declarations.h \ adg-gtk-area-private.h \ adg-gtk-layout-private.h \ adg-hatch-private.h \ + adg-internal.h \ + adg-introspection.h \ adg-ldim-private.h \ adg-line-style-private.h \ adg-logo-private.h \ adg-marker-private.h \ + adg-marshal.h \ adg-model-private.h \ - adg-path-private.h \ adg-pango-style-private.h \ + adg-path-private.h \ adg-projection-private.h \ adg-rdim-private.h \ adg-ruled-fill-private.h \ adg-stroke-private.h \ adg-table-private.h \ adg-table-style-private.h \ + adg-text-internal.h \ adg-text-private.h \ adg-title-block-private.h \ adg-toy-text-private.h \ adg-trail-private.h \ + adg-type-builtins.h \ test-internal.h HTML_IMAGES= content_files= diff --git a/src/adg.h.in b/src/adg.h.in index b5615e80..b7ca9077 100644 --- a/src/adg.h.in +++ b/src/adg.h.in @@ -24,6 +24,7 @@ #include #include +#include "adg/adg-forward-declarations.h" #include "adg/adg-enums.h" #include "adg/adg-utils.h" #include "adg/adg-pair.h" diff --git a/src/adg/Makefile.am b/src/adg/Makefile.am index 5c3c3c72..fcbccc6e 100644 --- a/src/adg/Makefile.am +++ b/src/adg/Makefile.am @@ -25,6 +25,7 @@ h_sources= adg-adim.h \ adg-enums.h \ adg-fill-style.h \ adg-font-style.h \ + adg-forward-declarations.h \ adg-hatch.h \ adg-ldim.h \ adg-line-style.h \ diff --git a/src/adg/adg-canvas.h.in b/src/adg/adg-canvas.h.in index 1f29fe93..3a59b2a6 100644 --- a/src/adg/adg-canvas.h.in +++ b/src/adg/adg-canvas.h.in @@ -35,12 +35,8 @@ G_BEGIN_DECLS #define ADG_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), ADG_TYPE_CANVAS)) #define ADG_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ADG_TYPE_CANVAS, AdgCanvasClass)) -#if 0 -/* AdgCanvas declared in adg-entity.h */ -typedef struct _AdgCanvas AdgCanvas; -#endif -typedef struct _AdgCanvasClass AdgCanvasClass; +typedef struct _AdgCanvasClass AdgCanvasClass; struct _AdgCanvas { /*< private >*/ diff --git a/src/adg/adg-dim.c b/src/adg/adg-dim.c index bcf18de0..5261e1df 100644 --- a/src/adg/adg-dim.c +++ b/src/adg/adg-dim.c @@ -238,7 +238,7 @@ adg_dim_init(AdgDim *dim) data->max = NULL; #if 0 - /* These ones are G_PARAM_CONSTRUCT, so initialized by GObject */ + /* This one is G_PARAM_CONSTRUCT, so set by property inizialization */ data->value = NULL #endif diff --git a/src/adg/adg-dress.h b/src/adg/adg-dress.h index 6607f40b..ce653f73 100644 --- a/src/adg/adg-dress.h +++ b/src/adg/adg-dress.h @@ -36,12 +36,6 @@ G_BEGIN_DECLS #define ADG_IS_PARAM_SPEC_DRESS(spec) (G_TYPE_CHECK_INSTANCE_TYPE((spec), ADG_TYPE_PARAM_SPEC_DRESS)) -/* The real AdgDress is defined in adg-entity.h */ -#if 0 -typedef struct _AdgDress AdgDress; -#endif - - GType adg_dress_get_type (void) G_GNUC_CONST; AdgDress adg_dress_new (const gchar *name, AdgStyle *fallback); diff --git a/src/adg/adg-entity.h b/src/adg/adg-entity.h index 9dfc9756..6b59228c 100644 --- a/src/adg/adg-entity.h +++ b/src/adg/adg-entity.h @@ -37,16 +37,8 @@ G_BEGIN_DECLS #define ADG_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ADG_TYPE_ENTITY, AdgEntityClass)) -/* Forward declarations */ -ADG_TYPEDEF(struct _AdgCanvas AdgCanvas); -ADG_TYPEDEF(struct _AdgStyle AdgStyle); -ADG_TYPEDEF(struct _AdgPoint AdgPoint); -ADG_TYPEDEF(gint AdgDress); - - -typedef struct _AdgEntity AdgEntity; -typedef struct _AdgEntityClass AdgEntityClass; - +typedef struct _AdgEntity AdgEntity; +typedef struct _AdgEntityClass AdgEntityClass; struct _AdgEntity { /*< private >*/ diff --git a/src/adg/adg-forward-declarations.h b/src/adg/adg-forward-declarations.h new file mode 100644 index 00000000..218d9dd1 --- /dev/null +++ b/src/adg/adg-forward-declarations.h @@ -0,0 +1,50 @@ +/* ADG - Automatic Drawing Generation + * Copyright (C) 2007,2008,2009,2010,2011,2012 Nicola Fontana + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + + +#if !defined(__ADG_H__) +#error "Only can be included directly." +#endif + + +#ifndef __ADG_FORWARD_DECLARATIONS_H__ +#define __ADG_FORWARD_DECLARATIONS_H__ + + +G_BEGIN_DECLS + +/* Forward declarations are kept in a separate file so it can be + * easily skipped by gtkdoc-scan: gtk-doc is inclined to mess up + * sections when forward declarations are used. + */ + +/* Needed by adg-entity.h */ +typedef struct _AdgCanvas AdgCanvas; +typedef struct _AdgStyle AdgStyle; +typedef struct _AdgPoint AdgPoint; +typedef gint AdgDress; + +/* Needed by adg-table.h */ +typedef struct _AdgTableRow AdgTableRow; +typedef struct _AdgTableCell AdgTableCell; + +G_END_DECLS + + +#endif /* __ADG_FORWARD_DECLARATIONS_H__ */ diff --git a/src/adg/adg-internal.h b/src/adg/adg-internal.h index a7f9050a..b22c3301 100644 --- a/src/adg/adg-internal.h +++ b/src/adg/adg-internal.h @@ -43,6 +43,7 @@ #include /* ADG headers basically included by every source file */ +#include "adg-forward-declarations.h" #include "adg-enums.h" #include "adg-utils.h" #include "adg-pair.h" diff --git a/src/adg/adg-matrix.h b/src/adg/adg-matrix.h index 497667af..85bb8d20 100644 --- a/src/adg/adg-matrix.h +++ b/src/adg/adg-matrix.h @@ -29,13 +29,11 @@ G_BEGIN_DECLS -#define ADG_TYPE_MATRIX (adg_matrix_get_type()) +#define _AdgMatrix _cairo_matrix +#define ADG_TYPE_MATRIX (adg_matrix_get_type()) -ADG_TYPEDEF(cairo_matrix_t AdgMatrix); -#if 0 typedef struct _AdgMatrix AdgMatrix; -#endif GType adg_matrix_get_type (void) G_GNUC_CONST; diff --git a/src/adg/adg-point.h b/src/adg/adg-point.h index 19becdfe..16c85980 100644 --- a/src/adg/adg-point.h +++ b/src/adg/adg-point.h @@ -31,11 +31,6 @@ G_BEGIN_DECLS #define ADG_TYPE_POINT (adg_point_get_type()) -#if 0 -/* This is declared in adg-entity.h */ -typedef struct _AdgPoint AdgPoint; -#endif - GType adg_point_get_type (void) G_GNUC_CONST; diff --git a/src/adg/adg-style.h b/src/adg/adg-style.h index 9e4fa2a9..e1edd01b 100644 --- a/src/adg/adg-style.h +++ b/src/adg/adg-style.h @@ -37,10 +37,6 @@ G_BEGIN_DECLS #define ADG_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ADG_TYPE_STYLE, AdgStyleClass)) -#if 0 -/* This is declared in adg-entity.h */ -typedef struct _AdgStyle AdgStyle; -#endif typedef struct _AdgStyleClass AdgStyleClass; struct _AdgStyle { diff --git a/src/adg/adg-table-cell.h b/src/adg/adg-table-cell.h index 6a36597f..ace575b2 100644 --- a/src/adg/adg-table-cell.h +++ b/src/adg/adg-table-cell.h @@ -32,12 +32,6 @@ G_BEGIN_DECLS #define ADG_TYPE_TABLE_CELL (adg_table_cell_get_type()) -#if 0 -/* AdgTableCell declared in adg-table.h */ -typedef struct _AdgTableCell AdgTableCell; -#endif - - GType adg_table_cell_get_type (void) G_GNUC_CONST; AdgTableCell * adg_table_cell_dup (const AdgTableCell *table_cell); diff --git a/src/adg/adg-table-row.h b/src/adg/adg-table-row.h index 5bbbdd70..85081809 100644 --- a/src/adg/adg-table-row.h +++ b/src/adg/adg-table-row.h @@ -32,12 +32,6 @@ G_BEGIN_DECLS #define ADG_TYPE_TABLE_ROW (adg_table_row_get_type()) -#if 0 -/* AdgTableRow declared in adg-table.h */ -typedef struct _AdgTableRow AdgTableRow; -#endif - - GType adg_table_row_get_type (void) G_GNUC_CONST; AdgTableRow * adg_table_row_dup (const AdgTableRow *table_row); diff --git a/src/adg/adg-table.h b/src/adg/adg-table.h index 1b087a26..3bb2df93 100644 --- a/src/adg/adg-table.h +++ b/src/adg/adg-table.h @@ -37,11 +37,6 @@ G_BEGIN_DECLS #define ADG_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ADG_TYPE_TABLE, AdgTableClass)) -/* Forward declarations */ -ADG_TYPEDEF(struct _AdgTableRow AdgTableRow); -ADG_TYPEDEF(struct _AdgTableCell AdgTableCell); - - typedef struct _AdgTable AdgTable; typedef struct _AdgTableClass AdgTableClass; diff --git a/src/adg/adg-utils.c b/src/adg/adg-utils.c index a82880fb..6749825d 100644 --- a/src/adg/adg-utils.c +++ b/src/adg/adg-utils.c @@ -30,30 +30,6 @@ **/ /** - * ADG_TYPEDEF: - * @t: the typedef content - * - * This is a really bad hack to fool gtk-doc. It performs the same job - * as the typedef reserved word but, being in the form of a macro, it - * it not properly understood by gtk-doc. This makes possible to force - * the parsing of a type such as in the following example: - * - * |[ - * ADG_TYPEDEF(cairo_matrix_t AdgMatrix); - * #if 0 - * typedef struct _AdgMatrix AdgMatrix; - * #endif - * ]| - * - * This kind of foolishness is needed in order to have the name of the - * generated file match the type without having a double id error. - * Check bug #593282 for details: - * http://bugzilla.gnome.org/show_bug.cgi?id=593282 - * - * Since: 1.0 - **/ - -/** * ADG_DIR_RIGHT: * * Symbolic constant for the right direction (in radians). diff --git a/src/adg/adg-utils.h b/src/adg/adg-utils.h index 5f51acbc..b918e413 100644 --- a/src/adg/adg-utils.h +++ b/src/adg/adg-utils.h @@ -27,8 +27,6 @@ #define __ADG_UTILS_H__ -#define ADG_TYPEDEF(t) typedef t - #define ADG_DIR_RIGHT 0. #define ADG_DIR_DOWN G_PI_2 #define ADG_DIR_LEFT G_PI -- 2.11.4.GIT