[vala] mysql: Automatically get length of arrays returned by Result methods.



commit d387b1c20d23e821083997164850011ecb4f1ccd
Author: Evan Nemerson <evan coeus-group com>
Date:   Sat Oct 2 15:00:05 2010 -0700

    mysql: Automatically get length of arrays returned by Result methods.

 vapi/mysql.vapi |   34 ++++++++++++++++++++++++++++------
 1 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/vapi/mysql.vapi b/vapi/mysql.vapi
index 4fdb85b..b0a0acb 100644
--- a/vapi/mysql.vapi
+++ b/vapi/mysql.vapi
@@ -223,12 +223,34 @@ namespace Mysql {
 		public bool eof ();
 		public Field* fetch_field ();
 		public Field* fetch_field_direct (uint field_nbr);
-		[CCode (array_length = false)]
-		public unowned Field[] fetch_fields ();
-		[CCode (array_length = false)]
-		public unowned ulong[] fetch_lengths ();
-		[CCode (array_length = false)]
-		public unowned string[]? fetch_row ();		
+
+		[CCode (cname = "mysql_fetch_fields", array_length = false)]
+		public unowned Field[] _fetch_fields ();
+		[CCode (cname = "_vala_mysql_fetch_fields")]
+		public unowned Field[] fetch_fields () {
+			unowned Field[] fields = this._fetch_fields ();
+			fields.length = (int) this.num_fields ();
+			return fields;
+		}
+
+		[CCode (cname = "mysql_fetch_lengths", array_length = false)]
+		public unowned ulong[] _fetch_lengths ();
+		[CCode (cname = "_vala_mysql_fetch_lengths")]
+		public unowned ulong[] fetch_lengths () {
+			unowned ulong[] lengths = this._fetch_lengths ();
+			lengths.length = (int) this.num_fields ();
+			return lengths;
+		}
+
+		[CCode (cname = "mysql_fetch_row", array_length = false)]
+		public unowned string[]? _fetch_row ();
+		[CCode (cname = "_vala_mysql_fetch_row")]
+		public unowned string[]? fetch_row () {
+			unowned string[]? row = this._fetch_row ();
+			row.length = (int) this.num_fields ();
+			return row;
+		}
+
 		public uint fetch_count ();
 		public uint num_fields ();
 		public uint num_rows ();



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