diff options
author | Joe Shaw <joeshaw@novell.com> | 2005-09-08 18:54:42 +0000 |
---|---|---|
committer | Joe Shaw <joeshaw@novell.com> | 2005-09-08 18:54:42 +0000 |
commit | 24c6ddc1a41e280c877233f98569d4e21d12f1ef (patch) | |
tree | a318f931347f3d43cd22f1b56461a4ecec67c4f8 /mono/DBusType/Array.cs | |
parent | 76faf9aa9c05dac0d3397867d8f317c3eb9cc0bc (diff) |
2005-09-08 Joe Shaw <joeshaw@novell.com>
Patches from James Willcox <snorp@snorp.net>
* 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.
Diffstat (limited to 'mono/DBusType/Array.cs')
-rw-r--r-- | mono/DBusType/Array.cs | 25 |
1 files changed, 21 insertions, 4 deletions
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; } |