[gnome-db] patch for gda-value
- From: Gonzalo Paniagua Javier <gonzalo gnome-db org>
- To: Gnome-db list <gnome-db-list gnome org>
- Subject: [gnome-db] patch for gda-value
- Date: 24 Jul 2003 03:24:25 +0200
Here's the patch to use 'const' where appropiate in gda-value.c
Ok to commit?
-Gonzalo
? libgda/.gda-value.c.swp
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/ChangeLog,v
retrieving revision 1.542
diff -u -r1.542 ChangeLog
--- ChangeLog 24 Jul 2003 01:00:02 -0000 1.542
+++ ChangeLog 24 Jul 2003 01:23:12 -0000
@@ -1,5 +1,9 @@
2003-07-24 Gonzalo Paniagua Javier <gonzalo gnome-db org>
+ * libgda/gda-value.[ch]: const'ified. Removed some warnings.
+
+2003-07-24 Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
* lexer.l:
* parser.y:
* sql_display.c:
Index: libgda/gda-value.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-value.c,v
retrieving revision 1.51
diff -u -r1.51 gda-value.c
--- libgda/gda-value.c 22 Jun 2003 18:05:01 -0000 1.51
+++ libgda/gda-value.c 24 Jul 2003 01:23:13 -0000
@@ -825,7 +825,7 @@
* Returns: the #GdaValueType of the value.
*/
GdaValueType
-gda_value_get_type (GdaValue *value)
+gda_value_get_type (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, GDA_VALUE_TYPE_UNKNOWN);
return value->type;
@@ -841,7 +841,7 @@
* #GDA_VALUE_TYPE_NULL.
*/
gboolean
-gda_value_is_null (GdaValue *value)
+gda_value_is_null (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, FALSE);
return value->type == GDA_VALUE_TYPE_NULL;
@@ -857,7 +857,7 @@
* Returns: TRUE if a number, FALSE otherwise.
*/
gboolean
-gda_value_is_number (GdaValue *value)
+gda_value_is_number (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, FALSE);
@@ -994,7 +994,7 @@
* Returns: the value contained in @value.
*/
gint64
-gda_value_get_bigint (GdaValue *value)
+gda_value_get_bigint (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_BIGINT), -1);
@@ -1027,7 +1027,7 @@
* Returns: the value contained in @value.
*/
guint64
-gda_value_get_biguint (GdaValue *value)
+gda_value_get_biguint (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_BIGUINT), -1);
@@ -1060,10 +1060,10 @@
*
* Returns: the value contained in @value.
*/
-gconstpointer
-gda_value_get_binary (GdaValue *value, glong *size)
+G_CONST_RETURN gpointer
+gda_value_get_binary (const GdaValue *value, glong *size)
{
- gconstpointer val;
+ gpointer val;
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_BINARY), NULL);
@@ -1104,7 +1104,7 @@
* Returns: the value contained in @value.
*/
gboolean
-gda_value_get_boolean (GdaValue *value)
+gda_value_get_boolean (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, FALSE);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_BOOLEAN), FALSE);
@@ -1136,8 +1136,8 @@
*
* Returns: the value contained in @value.
*/
-const GdaDate *
-gda_value_get_date (GdaValue *value)
+G_CONST_RETURN GdaDate *
+gda_value_get_date (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_DATE), NULL);
@@ -1173,7 +1173,7 @@
* Returns: the value contained in @value.
*/
gdouble
-gda_value_get_double (GdaValue *value)
+gda_value_get_double (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_DOUBLE), -1);
@@ -1205,8 +1205,8 @@
*
* Returns: the value contained in @value.
*/
-const GdaGeometricPoint *
-gda_value_get_geometric_point (GdaValue *value)
+G_CONST_RETURN GdaGeometricPoint *
+gda_value_get_geometric_point (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_GEOMETRIC_POINT), NULL);
@@ -1238,8 +1238,8 @@
*
* Gets the value stored in @value.
*/
-const GObject *
-gda_value_get_gobject (GdaValue *value)
+G_CONST_RETURN GObject *
+gda_value_get_gobject (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_GOBJECT), NULL);
@@ -1274,7 +1274,7 @@
* Returns: the value contained in @value.
*/
gint
-gda_value_get_integer (GdaValue *value)
+gda_value_get_integer (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_INTEGER), -1);
@@ -1306,8 +1306,8 @@
*
* Returns: the value contained in @value.
*/
-const GdaValueList *
-gda_value_get_list (GdaValue *value)
+G_CONST_RETURN GdaValueList *
+gda_value_get_list (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_LIST), NULL);
@@ -1338,8 +1338,8 @@
*
* Returns: the value contained in @value.
*/
-const GdaMoney *
-gda_value_get_money (GdaValue *value)
+G_CONST_RETURN GdaMoney *
+gda_value_get_money (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_MONEY), NULL);
@@ -1388,8 +1388,8 @@
*
* Returns: the value contained in @value.
*/
-const GdaNumeric *
-gda_value_get_numeric (GdaValue *value)
+G_CONST_RETURN GdaNumeric *
+gda_value_get_numeric (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_NUMERIC), NULL);
@@ -1425,7 +1425,7 @@
* Returns: the value contained in @value.
*/
gfloat
-gda_value_get_single (GdaValue *value)
+gda_value_get_single (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_SINGLE), -1);
@@ -1458,7 +1458,7 @@
* Returns: the value contained in @value.
*/
gshort
-gda_value_get_smallint (GdaValue *value)
+gda_value_get_smallint (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_SMALLINT), -1);
@@ -1491,7 +1491,7 @@
* Returns: the value contained in @value.
*/
gushort
-gda_value_get_smalluint (GdaValue *value)
+gda_value_get_smalluint (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_SMALLUINT), -1);
@@ -1524,7 +1524,7 @@
* Returns: the value contained in @value.
*/
const gchar *
-gda_value_get_string (GdaValue *value)
+gda_value_get_string (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_STRING), NULL);
@@ -1557,7 +1557,7 @@
* Returns: the value contained in @value.
*/
const GdaTime *
-gda_value_get_time (GdaValue *value)
+gda_value_get_time (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_TIME), NULL);
@@ -1594,7 +1594,7 @@
* Returns: the value contained in @value.
*/
const GdaTimestamp *
-gda_value_get_timestamp (GdaValue *value)
+gda_value_get_timestamp (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_TIMESTAMP), NULL);
@@ -1635,7 +1635,7 @@
* Returns: the value contained in @value.
*/
gchar
-gda_value_get_tinyint (GdaValue *value)
+gda_value_get_tinyint (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_TINYINT), -1);
@@ -1668,7 +1668,7 @@
* Returns: the value contained in @value.
*/
guchar
-gda_value_get_tinyuint (GdaValue *value)
+gda_value_get_tinyuint (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_TINYUINT), -1);
@@ -1701,7 +1701,7 @@
* Returns: the value contained in @value.
*/
guint
-gda_value_get_uinteger (GdaValue *value)
+gda_value_get_uinteger (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, -1);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_UINTEGER), -1);
@@ -1734,7 +1734,7 @@
* Returns: the value contained in @value.
**/
GdaValueType
-gda_value_get_vtype (GdaValue *value)
+gda_value_get_vtype (const GdaValue *value)
{
g_return_val_if_fail (value != NULL, GDA_VALUE_TYPE_UNKNOWN);
g_return_val_if_fail (gda_value_isa (value, GDA_VALUE_TYPE_TYPE), GDA_VALUE_TYPE_UNKNOWN);
@@ -1891,7 +1891,7 @@
* the preceding table.
*/
gchar *
-gda_value_stringify (GdaValue *value)
+gda_value_stringify (const GdaValue *value)
{
const GdaTime *gdatime;
const GdaDate *gdadate;
@@ -1910,7 +1910,7 @@
retval = g_strdup_printf ("%lld", gda_value_get_bigint (value));
break;
case GDA_VALUE_TYPE_BIGUINT:
- retval = g_strdup_printf ("%lud", gda_value_get_biguint (value));
+ retval = g_strdup_printf ("%llu", gda_value_get_biguint (value));
break;
case GDA_VALUE_TYPE_BINARY :
retval = g_malloc0 (value->binary_length + 1);
@@ -1957,7 +1957,7 @@
gdatime->hour,
gdatime->minute,
gdatime->second,
- gdatime->timezone / 3600);
+ (int) gdatime->timezone / 3600);
break;
case GDA_VALUE_TYPE_DATE:
gdadate = gda_value_get_date (value);
@@ -1977,8 +1977,8 @@
timestamp->hour,
timestamp->minute,
timestamp->second,
- timestamp->fraction,
- timestamp->timezone/3600);
+ (int) timestamp->fraction,
+ (int) timestamp->timezone/3600);
break;
case GDA_VALUE_TYPE_GEOMETRIC_POINT:
point = gda_value_get_geometric_point (value);
@@ -2169,16 +2169,8 @@
* because of some localization with gda_value_stingify ().
*/
static gchar *
-to_string (GdaValue *value)
+to_string (const GdaValue *value)
{
- const GdaTime *gdatime;
- const GdaDate *gdadate;
- const GdaTimestamp *timestamp;
- const GdaGeometricPoint *point;
- const GdaValueList *list;
- const GdaNumeric *numeric;
- GList *l;
- GString *str = NULL;
gchar *retval = NULL;
g_return_val_if_fail (value != NULL, NULL);
@@ -2208,7 +2200,7 @@
* needed anymore, you should free it.
*/
xmlNodePtr
-gda_value_to_xml (GdaValue *value)
+gda_value_to_xml (const GdaValue *value)
{
gchar *valstr;
xmlNodePtr retval;
Index: libgda/gda-value.h
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-value.h,v
retrieving revision 1.31
diff -u -r1.31 gda-value.h
--- libgda/gda-value.h 22 Jun 2003 18:05:01 -0000 1.31
+++ libgda/gda-value.h 24 Jul 2003 01:23:13 -0000
@@ -161,56 +161,56 @@
void gda_value_free (GdaValue *value);
-GdaValueType gda_value_get_type (GdaValue *value);
+GdaValueType gda_value_get_type (const GdaValue *value);
#define gda_value_isa(value,type) (gda_value_get_type (value) == type)
-gboolean gda_value_is_null (GdaValue *value);
-gboolean gda_value_is_number (GdaValue *value);
+gboolean gda_value_is_null (const GdaValue *value);
+gboolean gda_value_is_number (const GdaValue *value);
GdaValue *gda_value_copy (const GdaValue *value);
-gint64 gda_value_get_bigint (GdaValue *value);
+gint64 gda_value_get_bigint (const GdaValue *value);
void gda_value_set_bigint (GdaValue *value, gint64 val);
-guint64 gda_value_get_biguint (GdaValue *value);
+guint64 gda_value_get_biguint (const GdaValue *value);
void gda_value_set_biguint (GdaValue *value, guint64 val);
-gconstpointer gda_value_get_binary (GdaValue *value, glong *size);
+G_CONST_RETURN gpointer gda_value_get_binary (const GdaValue *value, glong *size);
void gda_value_set_binary (GdaValue *value, gconstpointer val, glong size);
-gboolean gda_value_get_boolean (GdaValue *value);
+gboolean gda_value_get_boolean (const GdaValue *value);
void gda_value_set_boolean (GdaValue *value, gboolean val);
-const GdaDate *gda_value_get_date (GdaValue *value);
+G_CONST_RETURN GdaDate *gda_value_get_date (const GdaValue *value);
void gda_value_set_date (GdaValue *value, const GdaDate *val);
-gdouble gda_value_get_double (GdaValue *value);
+gdouble gda_value_get_double (const GdaValue *value);
void gda_value_set_double (GdaValue *value, gdouble val);
-const GdaGeometricPoint *gda_value_get_geometric_point (GdaValue *value);
+G_CONST_RETURN GdaGeometricPoint *gda_value_get_geometric_point (const GdaValue *value);
void gda_value_set_geometric_point (GdaValue *value, const GdaGeometricPoint *val);
-const GObject *gda_value_get_gobject (GdaValue *value);
+G_CONST_RETURN GObject *gda_value_get_gobject (const GdaValue *value);
void gda_value_set_gobject (GdaValue *value, const GObject *val);
-gint gda_value_get_integer (GdaValue *value);
+gint gda_value_get_integer (const GdaValue *value);
void gda_value_set_integer (GdaValue *value, gint val);
-const GdaValueList *gda_value_get_list (GdaValue *value);
+G_CONST_RETURN GdaValueList *gda_value_get_list (const GdaValue *value);
void gda_value_set_list (GdaValue *value, const GdaValueList *val);
void gda_value_set_null (GdaValue *value);
-const GdaMoney *gda_value_get_money (GdaValue *value);
+G_CONST_RETURN GdaMoney *gda_value_get_money (const GdaValue *value);
void gda_value_set_money (GdaValue *value, const GdaMoney *val);
-const GdaNumeric *gda_value_get_numeric (GdaValue *value);
+G_CONST_RETURN GdaNumeric *gda_value_get_numeric (const GdaValue *value);
void gda_value_set_numeric (GdaValue *value, const GdaNumeric *val);
-gfloat gda_value_get_single (GdaValue *value);
+gfloat gda_value_get_single (const GdaValue *value);
void gda_value_set_single (GdaValue *value, gfloat val);
-gshort gda_value_get_smallint (GdaValue *value);
+gshort gda_value_get_smallint (const GdaValue *value);
void gda_value_set_smallint (GdaValue *value, gshort val);
-gushort gda_value_get_smalluint (GdaValue *value);
+gushort gda_value_get_smalluint (const GdaValue *value);
void gda_value_set_smalluint (GdaValue *value, gushort val);
-const gchar *gda_value_get_string (GdaValue *value);
+G_CONST_RETURN gchar *gda_value_get_string (const GdaValue *value);
void gda_value_set_string (GdaValue *value, const gchar *val);
-const GdaTime *gda_value_get_time (GdaValue *value);
+G_CONST_RETURN GdaTime *gda_value_get_time (const GdaValue *value);
void gda_value_set_time (GdaValue *value, const GdaTime *val);
-const GdaTimestamp *gda_value_get_timestamp (GdaValue *value);
+G_CONST_RETURN GdaTimestamp *gda_value_get_timestamp (const GdaValue *value);
void gda_value_set_timestamp (GdaValue *value, const GdaTimestamp *val);
-gchar gda_value_get_tinyint (GdaValue *value);
+gchar gda_value_get_tinyint (const GdaValue *value);
void gda_value_set_tinyint (GdaValue *value, gchar val);
-guchar gda_value_get_tinyuint (GdaValue *value);
+guchar gda_value_get_tinyuint (const GdaValue *value);
void gda_value_set_tinyuint (GdaValue *value, guchar val);
-guint gda_value_get_uinteger (GdaValue *value);
+guint gda_value_get_uinteger (const GdaValue *value);
void gda_value_set_uinteger (GdaValue *value, guint val);
-GdaValueType gda_value_get_vtype (GdaValue *value);
+GdaValueType gda_value_get_vtype (const GdaValue *value);
void gda_value_set_vtype (GdaValue *value, GdaValueType type);
gboolean gda_value_set_from_string (GdaValue *value,
const gchar *as_string,
@@ -220,8 +220,8 @@
gint gda_value_compare (const GdaValue *value1,
const GdaValue *value2);
-gchar *gda_value_stringify (GdaValue *value);
-xmlNodePtr gda_value_to_xml (GdaValue *value);
+gchar *gda_value_stringify (const GdaValue *value);
+xmlNodePtr gda_value_to_xml (const GdaValue *value);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]