From 24c6ddc1a41e280c877233f98569d4e21d12f1ef Mon Sep 17 00:00:00 2001 From: Joe Shaw Date: Thu, 8 Sep 2005 18:54:42 +0000 Subject: 2005-09-08 Joe Shaw Patches from James Willcox * mono/Makefile.am: Add Int16.cs and UInt16.cs * mono/DBusType/Array.cs: Handle multidimensional arrays, and support array "out" parameters. * mono/DBusType/Int16.cs, mono/DBusType/UInt16.cs: New files, for 16-bit int support. --- mono/DBusType/Array.cs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'mono/DBusType/Array.cs') diff --git a/mono/DBusType/Array.cs b/mono/DBusType/Array.cs index ef001b98..3279b5aa 100644 --- a/mono/DBusType/Array.cs +++ b/mono/DBusType/Array.cs @@ -17,7 +17,7 @@ namespace DBus.DBusType private ArrayList elements; private Type elementType; private Service service = null; - + private Array() { } @@ -53,14 +53,30 @@ namespace DBus.DBusType Marshal.FreeCoTaskMem(arrayIter); } + + public string GetElementCodeAsString () + { + string ret = System.String.Empty; + Type t = val.GetType ().GetElementType (); + + while (true) { + ret += Arguments.GetCodeAsString (Arguments.MatchType(t)); + + if (t.IsArray) + t = t.GetElementType (); + else + break; + } + + return ret; + } public void Append(IntPtr iter) { IntPtr arrayIter = Marshal.AllocCoTaskMem (Arguments.DBusMessageIterSize); if (!dbus_message_iter_open_container (iter, - (int) Code, - Arguments.GetCodeAsString (elementType), + (int) Code, GetElementCodeAsString(), arrayIter)) { throw new ApplicationException("Failed to append array argument: " + val); } @@ -82,7 +98,8 @@ namespace DBus.DBusType public static bool Suits(System.Type type) { - if (type.IsArray) { + Type type2 = type.GetElementType (); + if (type.IsArray || (type2 != null && type2.IsArray)) { return true; } -- cgit