diff options
author | Joe Shaw <joeshaw@novell.com> | 2005-01-25 19:47:13 +0000 |
---|---|---|
committer | Joe Shaw <joeshaw@novell.com> | 2005-01-25 19:47:13 +0000 |
commit | b0002eb697ec4b1e35846b51d9e6e1a7824e0b03 (patch) | |
tree | d14e5cdc6646cb3de31d6e9e9ded564ac7bff82a /mono/DBusType/Custom.cs | |
parent | f4d4d5ace5804acc363fbcff51fbdc82c078702b (diff) |
2005-01-25 Joe Shaw <joeshaw@novell.com>
* Land the mono binding changes to conform to the new APIs.
* mono/Makefile.am: Remove Custom.cs, DBusType/Custom.cs,
DBusType/Dict.cs, and DBusType/Nil.cs from the build.
* mono/Arguments.cs (GetCodeAsString): Added. Returns the dbus
type code as a string.
(InitAppending): Rename dbus_message_append_iter_init() to
dbus_message_iter_init_append().
* mono/BusDriver.cs: Rename ServiceEventHandler to
NameOwnerChangedHandler. Rename GetServiceOwner to GetOwner.
Rename ServiceOwnerChanged to NameOwnerChanged.
* mono/Connection.cs: Rename BaseService to UniqueName, and the
underlying C call.
* mono/Custom.cs: Removed. The CUSTOM type has been removed.
* mono/Service.cs: Rename Exists to HasOwner, internally rename
dbus_bus_acquire_service() to dbus_bus_request_name().
* mono/DBusType/Array.cs (ctor): Use Type.GetElementType() instead
of Type.UnderlyingSystemType to get the correct element type for
the array.
(ctor): Update code for new APIs: use dbus_message_iter_recurse(),
dbus_message_get_{element|arg}_type() instead of
dbus_message_iter_init_array_iterator().
(Append): Replace dbus_message_iter_append_array() with
dbus_message_iter_open_container() and
dbus_message_iter_close_container().
* mono/DBusType/Custom.cs, mono/DBusType/Nil.cs: Removed. These
types have been removed.
* mono/DBusType/*.cs: Replace calls of
dbus_message_iter_get_[type]() to dbus_message_iter_get_basic(),
but specify the type in the DllImport extern declaration. Ditto
for dbus_message_iter_append_[type]() ->
dbus_message_iter_append_basic().
* mono/example/BusListener.cs: Update for ServiceEventHandler ->
NameOwnerChangedHandler.
Diffstat (limited to 'mono/DBusType/Custom.cs')
-rw-r--r-- | mono/DBusType/Custom.cs | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/mono/DBusType/Custom.cs b/mono/DBusType/Custom.cs deleted file mode 100644 index 92560649..00000000 --- a/mono/DBusType/Custom.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Reflection.Emit; - -using DBus; - -namespace DBus.DBusType -{ - /// <summary> - /// A named byte array, used for custom types. - /// </summary> - public class Custom : IDBusType - { - public const char Code = 'c'; - private DBus.Custom val; - - private Custom() - { - } - - public Custom(DBus.Custom val, Service service) - { - this.val = val; - } - - public Custom(IntPtr iter, Service service) - { - string name; - IntPtr value; - int len; - - if (!dbus_message_iter_get_custom(iter, out name, out value, out len)) { - throw new ApplicationException("Failed to get CUSTOM argument."); - } - - this.val.Name = name; - this.val.Data = new byte[len]; - Marshal.Copy(value, this.val.Data, 0, len); - } - - public void Append(IntPtr iter) - { - IntPtr data = Marshal.AllocCoTaskMem(this.val.Data.Length); - try { - Marshal.Copy(this.val.Data, 0, data, this.val.Data.Length); - if (!dbus_message_iter_append_custom(iter, this.val.Name, data, this.val.Data.Length)) { - throw new ApplicationException("Failed to append CUSTOM argument:" + val); - } - } finally { - Marshal.FreeCoTaskMem(data); - } - } - - public static bool Suits(System.Type type) - { - switch (type.ToString()) { - case "DBus.Custom": - case "DBus.Custom&": - return true; - } - - return false; - } - - public static void EmitMarshalIn(ILGenerator generator, Type type) - { - if (type.IsByRef) { - generator.Emit(OpCodes.Ldobj, type); - } - } - - public static void EmitMarshalOut(ILGenerator generator, Type type, bool isReturn) - { - generator.Emit(OpCodes.Unbox, type); - generator.Emit(OpCodes.Ldobj, type); - if (!isReturn) { - generator.Emit(OpCodes.Stobj, type); - } - } - - public object Get() - { - return this.val; - } - - public object Get(System.Type type) - { - switch (type.ToString()) { - case "DBus.Custom": - case "DBus.Custom&": - return this.val; - default: - throw new ArgumentException("Cannot cast DBus.Type.Custom to type '" + type.ToString() + "'"); - } - } - - [DllImport("dbus-1")] - private extern static bool dbus_message_iter_get_custom(IntPtr iter, - out string name, - out IntPtr value, - out int len); - - [DllImport("dbus-1")] - private extern static bool dbus_message_iter_append_custom(IntPtr iter, - string name, - IntPtr data, - int len); - } -} |