[tracker/harmattan-pre-signal-updates: 1346/1380] libtracker-sparql: Change column type to int from uint



commit 617bfb65a2158e79e69d84234cbc2a2a4956a82b
Author: Martyn Russell <martyn lanedo com>
Date:   Thu Sep 16 09:42:00 2010 +0100

    libtracker-sparql: Change column type to int from uint

 src/libtracker-bus/tracker-array-cursor.vala  |    8 ++++----
 src/libtracker-bus/tracker-bus-fd-cursor.c    |   18 +++++++++---------
 src/libtracker-sparql/tracker-cursor.vala     |   18 +++++++++---------
 tests/functional-tests/shared-query-test.vala |    5 ++---
 4 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-array-cursor.vala b/src/libtracker-bus/tracker-array-cursor.vala
index 70e49fe..ecc1d51 100644
--- a/src/libtracker-bus/tracker-array-cursor.vala
+++ b/src/libtracker-bus/tracker-array-cursor.vala
@@ -33,19 +33,19 @@ internal class Tracker.Bus.ArrayCursor : Tracker.Sparql.Cursor {
 		this.var_names = var_names;
 	}
 
-	public override uint n_columns { get { return cols; } }
+	public override int n_columns { get { return cols; } }
 
-	public override Sparql.ValueType get_value_type (uint column)
+	public override Sparql.ValueType get_value_type (int column)
 	requires (current_row >= 0) {
 		return this.types[column];
 	}
 
-	public override unowned string? get_variable_name (uint column)
+	public override unowned string? get_variable_name (int column)
 	requires (current_row >= 0) {
 		return this.var_names[column];
 	}
 
-	public override unowned string? get_string (uint column, out long length = null)
+	public override unowned string? get_string (int column, out long length = null)
 	requires (current_row >= 0) {
 		unowned string str;
 
diff --git a/src/libtracker-bus/tracker-bus-fd-cursor.c b/src/libtracker-bus/tracker-bus-fd-cursor.c
index 6f1c3bb..7dacfd0 100644
--- a/src/libtracker-bus/tracker-bus-fd-cursor.c
+++ b/src/libtracker-bus/tracker-bus-fd-cursor.c
@@ -49,7 +49,7 @@ struct TrackerBusFDCursor {
 	int buffer_index;
 	long buffer_size;
 
-	guint n_columns;
+	gint n_columns;
 	int *offsets;
 	int *types;
 	char *data;
@@ -162,7 +162,7 @@ tracker_bus_fd_cursor_iter_next_finish (TrackerBusFDCursor *cursor,
 	return g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res));
 }
 
-static guint
+static gint
 tracker_bus_fd_cursor_get_n_columns (TrackerBusFDCursor *cursor)
 {
 	return cursor->n_columns;
@@ -170,7 +170,7 @@ tracker_bus_fd_cursor_get_n_columns (TrackerBusFDCursor *cursor)
 
 static TrackerSparqlValueType
 tracker_bus_fd_cursor_get_value_type (TrackerBusFDCursor *cursor,
-                                      guint               column)
+                                      gint                column)
 {
 	g_return_val_if_fail (cursor->types != NULL, TRACKER_SPARQL_VALUE_TYPE_UNBOUND);
 
@@ -180,7 +180,7 @@ tracker_bus_fd_cursor_get_value_type (TrackerBusFDCursor *cursor,
 
 static const gchar *
 tracker_bus_fd_cursor_get_variable_name (TrackerBusFDCursor *cursor,
-                                         guint               column)
+                                         gint                column)
 {
 	g_return_val_if_fail (cursor->variable_names != NULL, NULL);
 
@@ -189,7 +189,7 @@ tracker_bus_fd_cursor_get_variable_name (TrackerBusFDCursor *cursor,
 
 static const gchar *
 tracker_bus_fd_cursor_get_string (TrackerBusFDCursor *cursor,
-                                  guint               column,
+                                  gint                column,
                                   glong              *length)
 {
 	const gchar *str = NULL;
@@ -222,10 +222,10 @@ tracker_bus_fd_cursor_class_init (TrackerBusFDCursorClass *class)
 
 	object_class->finalize = tracker_bus_fd_cursor_finalize;
 
-	sparql_cursor_class->get_value_type = (TrackerSparqlValueType (*) (TrackerSparqlCursor *, guint)) tracker_bus_fd_cursor_get_value_type;
-	sparql_cursor_class->get_variable_name = (const gchar * (*) (TrackerSparqlCursor *, guint)) tracker_bus_fd_cursor_get_variable_name;
-	sparql_cursor_class->get_n_columns = (guint (*) (TrackerSparqlCursor *)) tracker_bus_fd_cursor_get_n_columns;
-	sparql_cursor_class->get_string = (const gchar * (*) (TrackerSparqlCursor *, guint, glong*)) tracker_bus_fd_cursor_get_string;
+	sparql_cursor_class->get_value_type = (TrackerSparqlValueType (*) (TrackerSparqlCursor *, gint)) tracker_bus_fd_cursor_get_value_type;
+	sparql_cursor_class->get_variable_name = (const gchar * (*) (TrackerSparqlCursor *, gint)) tracker_bus_fd_cursor_get_variable_name;
+	sparql_cursor_class->get_n_columns = (gint (*) (TrackerSparqlCursor *)) tracker_bus_fd_cursor_get_n_columns;
+	sparql_cursor_class->get_string = (const gchar * (*) (TrackerSparqlCursor *, gint, glong*)) tracker_bus_fd_cursor_get_string;
 	sparql_cursor_class->next = (gboolean (*) (TrackerSparqlCursor *, GCancellable *, GError **)) tracker_bus_fd_cursor_iter_next;
 	sparql_cursor_class->next_async = (void (*) (TrackerSparqlCursor *, GCancellable *, GAsyncReadyCallback, gpointer)) tracker_bus_fd_cursor_iter_next_async;
 	sparql_cursor_class->next_finish = (gboolean (*) (TrackerSparqlCursor *, GAsyncResult *, GError **)) tracker_bus_fd_cursor_iter_next_finish;
diff --git a/src/libtracker-sparql/tracker-cursor.vala b/src/libtracker-sparql/tracker-cursor.vala
index 4def94f..4311143 100644
--- a/src/libtracker-sparql/tracker-cursor.vala
+++ b/src/libtracker-sparql/tracker-cursor.vala
@@ -88,7 +88,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 	 *
 	 * Number of columns available in the results to iterate.
 	 */
-	public abstract uint n_columns {
+	public abstract int n_columns {
 		/**
 		 * tracker_sparql_cursor_get_n_columns:
 		 * @self: a #TrackerSparqlCursor
@@ -98,7 +98,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 		 * tracker_sparql_cursor_next(); otherwise its return value will be
 		 * undefined.
 		 *
-		 * Returns: a #guint with the number of columns.
+		 * Returns: a #gint with the number of columns.
 		 */
 		get;
 	}
@@ -112,7 +112,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 	 *
 	 * Returns: a value type
 	 */
-	public abstract ValueType get_value_type (uint column);
+	public abstract ValueType get_value_type (int column);
 
 	/**
 	 * tracker_sparql_cursor_get_variable_name:
@@ -123,7 +123,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 	 *
 	 * Returns: a string, which should not be freed by the caller.
 	 */
-	public abstract unowned string? get_variable_name (uint column);
+	public abstract unowned string? get_variable_name (int column);
 
 	/**
 	 * tracker_sparql_cursor_get_string:
@@ -136,7 +136,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 	 * Returns: a string, which should not be freed by the caller. #NULL
 	 * is returned if the column number is in the [0,#n_columns] range.
 	 */
-	public abstract unowned string? get_string (uint column, out long length = null);
+	public abstract unowned string? get_string (int column, out long length = null);
 
 	/**
 	 * tracker_sparql_cursor_next:
@@ -192,7 +192,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 	 *
 	 * Returns: a integer.
 	 */
-	public virtual int64 get_integer (uint column) {
+	public virtual int64 get_integer (int column) {
 		return_val_if_fail (get_value_type (column) == ValueType.INTEGER, 0);
 		unowned string as_str = get_string (column);
 		return as_str.to_int64();
@@ -207,7 +207,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 	 *
 	 * Returns: a double.
 	 */
-	public virtual double get_double (uint column) {
+	public virtual double get_double (int column) {
 		return_val_if_fail (get_value_type (column) == ValueType.DOUBLE, 0);
 		unowned string as_str = get_string (column);
 		return as_str.to_double();
@@ -222,7 +222,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 	 *
 	 * Returns: a boolean.
 	 */
-	public virtual bool get_boolean (uint column) {
+	public virtual bool get_boolean (int column) {
 		ValueType type = get_value_type (column);
 		return_val_if_fail (type == ValueType.BOOLEAN, 0);
 		unowned string as_str = get_string (column);
@@ -238,7 +238,7 @@ public abstract class Tracker.Sparql.Cursor : Object {
 	 *
 	 * Returns: a boolean.
 	 */
-	public virtual bool is_bound (uint column) {
+	public virtual bool is_bound (int column) {
 		if (get_value_type (column) != ValueType.UNBOUND) {
 			return true;
 		}
diff --git a/tests/functional-tests/shared-query-test.vala b/tests/functional-tests/shared-query-test.vala
index de122c2..3fb930c 100644
--- a/tests/functional-tests/shared-query-test.vala
+++ b/tests/functional-tests/shared-query-test.vala
@@ -35,16 +35,15 @@ public class TestApp : GLib.Object {
 	}
 
 	int iter_cursor (Cursor cursor) {
-		uint i;
+		int i;
 
 		try {
 			for (i = 0; i < cursor.n_columns; i++) {
 				print ("| %s ", cursor.get_variable_name (i));
 			}
-			print ("| -> %u columns\n", cursor.n_columns);
+			print ("| -> %d columns\n", cursor.n_columns);
 
 			while (cursor.next()) {
-
 				for (i = 0; i < cursor.n_columns; i++) {
 					print ("%s%s a %s", i != 0 ? ",":"",
 					       cursor.get_string (i),



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