[libgda] Make GdaGeometricPoint introspectable
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Make GdaGeometricPoint introspectable
- Date: Fri, 26 May 2017 20:43:37 +0000 (UTC)
commit 958ce20963e0a45d3137b041bf3d38eff9ba15ba
Author: Daniel Espinosa <esodan gmail com>
Date: Fri May 26 15:42:07 2017 -0500
Make GdaGeometricPoint introspectable
Fix bug:
https://bugzilla.gnome.org/show_bug.cgi?id=765774
doc/C/libgda-sections.txt | 2 +-
doc/C/libgda.types.in | 2 +-
libgda/gda-value.c | 82 +++++++++++++++++++++++---
libgda/gda-value.h | 27 ++++-----
libgda/libgda.symbols | 11 +++-
providers/postgres/gda-postgres-recordset.c | 7 +-
6 files changed, 98 insertions(+), 33 deletions(-)
---
diff --git a/doc/C/libgda-sections.txt b/doc/C/libgda-sections.txt
index ce0b269..75bd426 100644
--- a/doc/C/libgda-sections.txt
+++ b/doc/C/libgda-sections.txt
@@ -972,7 +972,7 @@ gda_value_get_ushort
gda_value_set_ushort
<SUBSECTION Standard>
gda_binary_get_type
-gda_geometricpoint_get_type
+gda_geometric_point_get_type
gda_numeric_get_type
gda_time_get_type
gda_timestamp_get_type
diff --git a/doc/C/libgda.types.in b/doc/C/libgda.types.in
index 1a63349..42f5fae 100644
--- a/doc/C/libgda.types.in
+++ b/doc/C/libgda.types.in
@@ -36,7 +36,7 @@ gda_server_operation_get_type
gda_server_provider_get_type
gda_transaction_status_get_type
gda_binary_get_type
-gda_geometricpoint_get_type
+gda_geometric_point_get_type
gda_numeric_get_type
gda_time_get_type
gda_timestamp_get_type
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index cde34a1..789b81d 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -651,7 +651,7 @@ gda_binary_free (GdaBinary *binary)
/**
* gda_value_new_binary: (skip)
- * @val: (transfert full): value to set for the new #GValue.
+ * @val: (transfer full): value to set for the new #GValue.
* @size: the size of the memory pool pointer to by @val.
*
* Makes a new #GValue of type #GDA_TYPE_BINARY with value @val.
@@ -832,6 +832,16 @@ gda_blob_set_op (GdaBlob *blob, GdaBlobOp *op)
}
}
+/**
+ * GdaGeometricPoint:
+ * @x:
+ * @y:
+ */
+struct _GdaGeometricPoint {
+ gdouble x;
+ gdouble y;
+};
+
/*
* Register the GdaGeometricPoint type in the GType system
*/
@@ -856,7 +866,7 @@ geometric_point_to_string (const GValue *src, GValue *dest)
/* Transform a String GValue to a GdaGeometricPoint from a string like "(3.2,5.6)" */
static void
-string_to_geometricpoint (const GValue *src, GValue *dest)
+string_to_geometric_point (const GValue *src, GValue *dest)
{
GdaGeometricPoint *point;
const gchar *as_string;
@@ -878,18 +888,18 @@ string_to_geometricpoint (const GValue *src, GValue *dest)
}
GType
-gda_geometricpoint_get_type (void)
+gda_geometric_point_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0)) {
type = g_boxed_type_register_static ("GdaGeometricPoint",
- (GBoxedCopyFunc) gda_geometricpoint_copy,
- (GBoxedFreeFunc) gda_geometricpoint_free);
+ (GBoxedCopyFunc) gda_geometric_point_copy,
+ (GBoxedFreeFunc) gda_geometric_point_free);
g_value_register_transform_func (G_TYPE_STRING,
type,
- string_to_geometricpoint);
+ string_to_geometric_point);
g_value_register_transform_func (type,
G_TYPE_STRING,
@@ -900,12 +910,12 @@ gda_geometricpoint_get_type (void)
}
/**
- * gda_geometricpoint_copy:
+ * gda_geometric_point_copy:
*
* Returns: (transfer full):
*/
gpointer
-gda_geometricpoint_copy (gpointer boxed)
+gda_geometric_point_copy (gpointer boxed)
{
GdaGeometricPoint *val = (GdaGeometricPoint*) boxed;
GdaGeometricPoint *copy;
@@ -920,12 +930,64 @@ gda_geometricpoint_copy (gpointer boxed)
}
void
-gda_geometricpoint_free (gpointer boxed)
+gda_geometric_point_free (gpointer boxed)
{
g_free (boxed);
}
+/**
+ * gda_geometric_point_new:
+ *
+ * Returns: (transfer full): a new #GdaGeometricPoint
+ */
+GdaGeometricPoint*
+gda_geometric_point_new (void)
+{
+ return g_new0 (GdaGeometricPoint, 1);
+}
+/**
+ * gda_geometric_point_get_x:
+ *
+ */
+gdouble
+gda_geometric_point_get_x (GdaGeometricPoint* gp)
+{
+ g_return_val_if_fail (gp != NULL, 0);
+ return gp->x;
+}
+/**
+ * gda_geometric_point_set_x:
+ *
+ */
+void
+gda_geometric_point_set_x (GdaGeometricPoint* gp, double x)
+{
+ g_return_if_fail (gp != NULL);
+ gp->x = x;
+}
+/**
+ * gda_geometric_point_get_y:
+ *
+ */
+gdouble
+gda_geometric_point_get_y (GdaGeometricPoint* gp)
+{
+ g_return_val_if_fail (gp != NULL, 0);
+ return gp->y;
+}
+/**
+ * gda_geometric_point_set_y:
+ *
+ */
+void
+gda_geometric_point_set_y (GdaGeometricPoint* gp, double y)
+{
+ g_return_if_fail (gp != NULL);
+ gp->y = y;
+}
+
+
/*
* Register the GdaNumeric type in the GType system
*/
@@ -2428,7 +2490,7 @@ gda_value_take_blob (GValue *value, GdaBlob *blob)
}
/**
- * gda_value_get_geometric_point: (skip)
+ * gda_value_get_geometric_point:
* @value: a #GValue whose value we want to get.
*
* Returns: (transfer none): the value stored in @value.
diff --git a/libgda/gda-value.h b/libgda/gda-value.h
index c30ae23..47ea699 100644
--- a/libgda/gda-value.h
+++ b/libgda/gda-value.h
@@ -44,7 +44,7 @@ G_BEGIN_DECLS
#define GDA_TYPE_NULL (gda_null_get_type())
#define GDA_TYPE_DEFAULT (gda_default_get_type())
#define GDA_TYPE_BLOB (gda_blob_get_type())
-#define GDA_TYPE_GEOMETRIC_POINT (gda_geometricpoint_get_type())
+#define GDA_TYPE_GEOMETRIC_POINT (gda_geometric_point_get_type())
#define GDA_TYPE_SHORT (gda_short_get_type())
#define GDA_TYPE_USHORT (gda_ushort_get_type())
#define GDA_TYPE_TIME (gda_time_get_type())
@@ -61,15 +61,6 @@ G_BEGIN_DECLS
#define GDA_VALUE_HOLDS_TIME(value) G_VALUE_HOLDS(value, GDA_TYPE_TIME)
#define GDA_VALUE_HOLDS_TIMESTAMP(value) G_VALUE_HOLDS(value, GDA_TYPE_TIMESTAMP)
-/**
- * GdaGeometricPoint:
- * @x:
- * @y:
- */
-typedef struct {
- gdouble x;
- gdouble y;
-} GdaGeometricPoint;
/* GdaNumeric */
typedef struct _GdaNumeric GdaNumeric;
@@ -216,9 +207,20 @@ const GdaBlob *gda_value_get_blob (const GValue *value);
void gda_value_set_blob (GValue *value, const GdaBlob *blob);
void gda_value_take_blob (GValue *value, GdaBlob *blob);
+typedef struct _GdaGeometricPoint GdaGeometricPoint;
+GType gda_geometric_point_get_type (void) G_GNUC_CONST;
+GdaGeometricPoint *gda_geometric_point_new (void);
+gdouble gda_geometric_point_get_x (GdaGeometricPoint* gp);
+void gda_geometric_point_set_x (GdaGeometricPoint* gp, double x);
+gdouble gda_geometric_point_get_y (GdaGeometricPoint* gp);
+void gda_geometric_point_set_y (GdaGeometricPoint* gp, double y);
+gpointer gda_geometric_point_copy (gpointer boxed);
+void gda_geometric_point_free (gpointer boxed);
const GdaGeometricPoint *gda_value_get_geometric_point (const GValue *value);
void gda_value_set_geometric_point (GValue *value, const GdaGeometricPoint
*val);
+
void gda_value_set_null (GValue *value);
+
const GdaNumeric *gda_value_get_numeric (const GValue *value);
void gda_value_set_numeric (GValue *value, const GdaNumeric *val);
gshort gda_value_get_short (const GValue *value);
@@ -286,11 +288,6 @@ void gda_timestamp_change_timezone (GdaTimestamp *t
const GdaTimestamp *gda_value_get_timestamp (const GValue *value);
void gda_value_set_timestamp (GValue *value, const GdaTimestamp *val);
-
-GType gda_geometricpoint_get_type (void) G_GNUC_CONST;
-gpointer gda_geometricpoint_copy (gpointer boxed);
-void gda_geometricpoint_free (gpointer boxed);
-
GType gda_short_get_type (void) G_GNUC_CONST;
GType gda_ushort_get_type (void) G_GNUC_CONST;
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index 90cd010..7272932 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -363,9 +363,14 @@
gda_dsn_split
gda_gbr_get_file_path
gda_gbr_init
- gda_geometricpoint_copy
- gda_geometricpoint_free
- gda_geometricpoint_get_type
+ gda_geometric_point_copy
+ gda_geometric_point_free
+ gda_geometric_point_get_type
+ gda_geometric_point_get_x
+ gda_geometric_point_set_x
+ gda_geometric_point_get_y
+ gda_geometric_point_set_y
+ gda_geometric_point_new
gda_get_application_exec_path
gda_g_type_from_string
gda_g_type_to_string
diff --git a/providers/postgres/gda-postgres-recordset.c b/providers/postgres/gda-postgres-recordset.c
index 777b41b..a523902 100644
--- a/providers/postgres/gda-postgres-recordset.c
+++ b/providers/postgres/gda-postgres-recordset.c
@@ -589,10 +589,10 @@ static void
make_point (GdaGeometricPoint *point, const gchar *value)
{
value++;
- point->x = g_ascii_strtod (value, NULL);
+ gda_geometricpoint_set_x (point, g_ascii_strtod (value, NULL));
value = strchr (value, ',');
value++;
- point->y = g_ascii_strtod (value, NULL);
+ gda_geometricpoint_set_y (point, g_ascii_strtod (value, NULL));
}
static void
@@ -666,9 +666,10 @@ set_value (GdaConnection *cnc, GdaRow *row, GValue *value, GType type, const gch
gda_numeric_free (numeric);
}
else if (type == GDA_TYPE_GEOMETRIC_POINT) {
- GdaGeometricPoint point;
+ GdaGeometricPoint* point = gda_geometric_point_new ();
make_point (&point, thevalue);
gda_value_set_geometric_point (value, &point);
+ gda_geometric_point_free (point);
}
else if (type == GDA_TYPE_TIMESTAMP) {
PostgresConnectionData *cdata;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]