[libgda] Enable GSEAL to find direct access to GdaNumeric members (no opaque struct)
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Enable GSEAL to find direct access to GdaNumeric members (no opaque struct)
- Date: Mon, 14 Nov 2011 18:32:56 +0000 (UTC)
commit 0b0232fbde0e6446404e0cac6677aae72b3a18e2
Author: Daniel Espinosa <despinosa src gnome org>
Date: Mon Nov 14 12:23:17 2011 -0600
Enable GSEAL to find direct access to GdaNumeric members (no opaque struct)
* make CFLAGS+="-DGSEAL_ENABLE" will fail to compile if direct access to
GdaNumeric members is intended
* Fixed internal SQLite and PostgreSQL providers, other providers must be
fixed too
libgda/gda-value.c | 30 +++++++++++++++++++++++++++
libgda/gda-value.h | 4 ++-
libgda/sqlite/gda-sqlite-provider.c | 2 +-
providers/postgres/gda-postgres-recordset.c | 12 +++++-----
4 files changed, 40 insertions(+), 8 deletions(-)
---
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 44c6f65..a65cb18 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -52,6 +52,35 @@
#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
#endif
+
+# ifdef GSEAL_ENABLE
+/**
+ * GdaNumeric:
+ * @number: a string representing a number
+ * @precision: precision to use when @number is converted (not implemented jet)
+ * @width: (not implemented jet)
+ *
+ * Holds numbers represented as strings.
+ *
+ * This struct must be considered as opaque. Any access to its members must use its
+ * accessors added since version 5.0.2.
+ *
+ * Set value func: gda_value_set_numeric
+ * Get value func: gda_value_get_numeric
+ */
+struct _GdaNumeric {
+ gchar* number;
+ glong precision;
+ glong width;
+
+ /*< private >*/
+ gpointer reserved; /* reserved for future usage with GMP (http://gmplib.org/) */
+};
+# else
+#endif
+
+
+
static gboolean
set_from_string (GValue *value, const gchar *as_string)
{
@@ -819,6 +848,7 @@ gda_numeric_get_type (void)
return type;
}
+
/**
* gda_numeric_copy:
* @boxed: source to get a copy from.
diff --git a/libgda/gda-value.h b/libgda/gda-value.h
index aeb2892..6673783 100644
--- a/libgda/gda-value.h
+++ b/libgda/gda-value.h
@@ -76,7 +76,8 @@ typedef struct {
typedef struct _GdaNumeric GdaNumeric;
-
+# ifdef GSEAL_ENABLE
+# else
/**
* GdaNumeric:
* @number: a string representing a number
@@ -99,6 +100,7 @@ struct _GdaNumeric {
/*< private >*/
gpointer reserved; /* reserved for future usage with GMP (http://gmplib.org/) */
};
+#endif
/**
* GdaTime:
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index 90a56d3..aaf9e4e 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -3245,7 +3245,7 @@ gda_sqlite_provider_statement_execute (GdaServerProvider *provider, GdaConnectio
const GdaNumeric *gdan;
gdan = gda_value_get_numeric (value);
- SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, gdan->number, -1, SQLITE_TRANSIENT);
+ SQLITE3_CALL (sqlite3_bind_text) (ps->sqlite_stmt, i, gda_numeric_get_string(gdan), -1, SQLITE_TRANSIENT);
}
else {
gchar *str;
diff --git a/providers/postgres/gda-postgres-recordset.c b/providers/postgres/gda-postgres-recordset.c
index 4fe09e8..0a0229a 100644
--- a/providers/postgres/gda-postgres-recordset.c
+++ b/providers/postgres/gda-postgres-recordset.c
@@ -649,12 +649,12 @@ set_value (GdaConnection *cnc, GdaRow *row, GValue *value, GType type, const gch
setlocale (LC_NUMERIC, gda_numeric_locale);
}
else if (type == GDA_TYPE_NUMERIC) {
- GdaNumeric numeric;
- numeric.number = g_strdup (thevalue);
- numeric.precision = 0; /* FIXME */
- numeric.width = 0; /* FIXME */
- gda_value_set_numeric (value, &numeric);
- g_free (numeric.number);
+ GdaNumeric* numeric = gda_numeric_new ();
+ gda_numeric_set_from_string (numeric, thevalue);
+ gda_numeric_set_precision (numeric, 0); /* FIXME */
+ gda_numeric_set_width (numeric, 0); /* FIXME */
+ gda_value_set_numeric (value, numeric);
+ gda_numeric_free (numeric);
}
else if (type == GDA_TYPE_GEOMETRIC_POINT) {
GdaGeometricPoint point;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]