[libgda/gtk3] Modified GdaMetaTableForeignKey to keep API but not ABI and make code more readable



commit 70766ec20fc8762c8ab9d74a8458a64bc2fdb91b
Author: Vivien Malerba <malerba gnome-db org>
Date:   Mon Feb 28 18:32:11 2011 +0100

    Modified GdaMetaTableForeignKey to keep API but not ABI and make code more readable

 libgda/gda-meta-struct.c |   22 ++++++++++++----------
 libgda/gda-meta-struct.h |   19 +++++++++++++------
 2 files changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/libgda/gda-meta-struct.c b/libgda/gda-meta-struct.c
index cccd3cc..996f7a8 100644
--- a/libgda/gda-meta-struct.c
+++ b/libgda/gda-meta-struct.c
@@ -1,6 +1,8 @@
-/* gda-meta-struct.c
+/*
+ * Copyright (C) 2008 - 2011 The GNOME Foundation.
  *
- * Copyright (C) 2008 - 2011 Vivien Malerba
+ * AUTHORS:
+ *      Vivien Malerba <malerba gnome-db org>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -697,10 +699,10 @@ add_declared_foreign_keys (GdaMetaStruct *mstruct, GdaMetaTable *mt, GError **er
 		/* create new FK structure */
 		tfk = g_new0 (GdaMetaTableForeignKey, 1);
 		tfk->meta_table = dbo;
-		tfk->declared = (gpointer) 0x01;
+		tfk->declared = TRUE;
 		tfk->fk_name = g_value_dup_string (fk_name);
-		tfk->on_update_policy = GINT_TO_POINTER (GDA_META_FOREIGN_KEY_NONE);
-		tfk->on_delete_policy = GINT_TO_POINTER (GDA_META_FOREIGN_KEY_NONE);
+		tfk->on_update_policy = GDA_META_FOREIGN_KEY_NONE;
+		tfk->on_delete_policy = GDA_META_FOREIGN_KEY_NONE;
 		
 		/* ignore if some columns are not found in the schema
 		 * (maybe wrong or outdated FK decl) */
@@ -1137,16 +1139,16 @@ _meta_struct_complement (GdaMetaStruct *mstruct, GdaMetaDbObjectType type,
 				dbo->depend_list = g_slist_append (dbo->depend_list, tfk->depend_on);
 
 				if (G_VALUE_TYPE (upd_policy) == G_TYPE_STRING)
-					tfk->on_update_policy = GINT_TO_POINTER (policy_string_to_value (g_value_get_string (upd_policy)));
+					tfk->on_update_policy = policy_string_to_value (g_value_get_string (upd_policy));
 				else
-					tfk->on_update_policy = GINT_TO_POINTER (GDA_META_FOREIGN_KEY_UNKNOWN);
+					tfk->on_update_policy = GDA_META_FOREIGN_KEY_UNKNOWN;
 
 				if (G_VALUE_TYPE (upd_policy) == G_TYPE_STRING)
-					tfk->on_delete_policy = GINT_TO_POINTER (policy_string_to_value (g_value_get_string (del_policy)));
+					tfk->on_delete_policy = policy_string_to_value (g_value_get_string (del_policy));
 				else
-					tfk->on_delete_policy = GINT_TO_POINTER (GDA_META_FOREIGN_KEY_UNKNOWN);
+					tfk->on_delete_policy = GDA_META_FOREIGN_KEY_UNKNOWN;
 
-				tfk->declared = NULL;
+				tfk->declared = FALSE;
 
 				/* FIXME: compute @cols_nb, and all the @*_array members (ref_pk_cols_array must be
 				 * initialized with -1 values everywhere */
diff --git a/libgda/gda-meta-struct.h b/libgda/gda-meta-struct.h
index e82af8c..7ff5b7c 100644
--- a/libgda/gda-meta-struct.h
+++ b/libgda/gda-meta-struct.h
@@ -338,17 +338,24 @@ typedef struct {
 	gchar           **ref_pk_names_array; /* Ref PK fields names */
 
 	/*< private >*/
-	gpointer          on_update_policy; /* pointer containing the GdaMetaForeignKeyPolicy integer
+	GdaMetaForeignKeyPolicy on_update_policy; /* pointer containing the GdaMetaForeignKeyPolicy integer
 					     * to keep ABI from 4.0, use GINT_TO_POINTER and
 					     * GPOINTER_TO_INT */
-	gpointer          on_delete_policy; /* pointer containing the GdaMetaForeignKeyPolicy integer
+	GdaMetaForeignKeyPolicy on_delete_policy; /* pointer containing the GdaMetaForeignKeyPolicy integer
 					     * to keep ABI from 4.0, use GINT_TO_POINTER and
 					     * GPOINTER_TO_INT */
-	gpointer          declared; /* pointer to a boolean to keep ABI from 4.0.
+	gboolean          declared; /* pointer to a boolean to keep ABI from 4.0.
 				     * Any non NULL if FK has been declared in meta data */
 
 	/*< public >*/
 	gchar            *fk_name;
+
+	/*< private >*/
+	/* Padding for future expansion */
+	gpointer _gda_reserved1;
+	gpointer _gda_reserved2;
+	gpointer _gda_reserved3;
+	gpointer _gda_reserved4;
 } GdaMetaTableForeignKey;
 /**
  * GDA_META_TABLE_FOREIGN_KEY
@@ -368,7 +375,7 @@ typedef struct {
  *
  * Returns: the policy as a #GdaMetaForeignKeyPolicy
  */
-#define GDA_META_TABLE_FOREIGN_KEY_ON_UPDATE_POLICY(fk) ((GdaMetaForeignKeyPolicy) GPOINTER_TO_INT ((GdaMetaTableForeignKey*)(fk)->on_update_policy))
+#define GDA_META_TABLE_FOREIGN_KEY_ON_UPDATE_POLICY(fk) (((GdaMetaTableForeignKey*)(fk))->on_update_policy)
 
 /**
  * GDA_META_TABLE_FOREIGN_KEY_ON_DELETE_POLICY:
@@ -378,7 +385,7 @@ typedef struct {
  *
  * Returns: the policy as a #GdaMetaForeignKeyPolicy
  */
-#define GDA_META_TABLE_FOREIGN_KEY_ON_DELETE_POLICY(fk) ((GdaMetaForeignKeyPolicy) GPOINTER_TO_INT ((GdaMetaTableForeignKey*)(fk)->on_delete_policy))
+#define GDA_META_TABLE_FOREIGN_KEY_ON_DELETE_POLICY(fk) (((GdaMetaTableForeignKey*)(fk))->on_delete_policy)
 
 /**
  * GDA_META_TABLE_FOREIGN_KEY_IS_DECLARED
@@ -389,7 +396,7 @@ typedef struct {
  *
  * Returns: %TRUE if @fk has been declared in the database's meta data and %FALSE if @fk is an actual foreign key defined in the database's schema
  */
-#define GDA_META_TABLE_FOREIGN_KEY_IS_DECLARED(fk) ((((GdaMetaTableForeignKey*)(fk))->declared) ? TRUE : FALSE)
+#define GDA_META_TABLE_FOREIGN_KEY_IS_DECLARED(fk) (((GdaMetaTableForeignKey*)(fk))->declared)
 
 GType               gda_meta_struct_get_type           (void) G_GNUC_CONST;
 GdaMetaStruct      *gda_meta_struct_new                (GdaMetaStore *store, GdaMetaStructFeature features);



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