2 using System.Runtime.InteropServices;
3 using System.Reflection.Emit;
7 namespace DBus.DBusType
10 /// 32-bit unsigned integer.
12 public class UInt32 : IDBusType
14 public const char Code = 'u';
15 private System.UInt32 val;
21 public UInt32(System.UInt32 val, Service service)
26 public UInt32(IntPtr iter, Service service)
28 this.val = dbus_message_iter_get_uint32(iter);
31 public void Append(IntPtr iter)
33 if (!dbus_message_iter_append_uint32(iter, val))
34 throw new ApplicationException("Failed to append UINT32 argument:" + val);
37 public static bool Suits(System.Type type)
39 if (type.IsEnum && type.UnderlyingSystemType == typeof(System.UInt32)) {
43 switch (type.ToString()) {
45 case "System.UInt32&":
52 public static void EmitMarshalIn(ILGenerator generator, Type type)
55 generator.Emit(OpCodes.Ldind_U4);
59 public static void EmitMarshalOut(ILGenerator generator, Type type, bool isReturn)
61 generator.Emit(OpCodes.Unbox, type);
62 generator.Emit(OpCodes.Ldind_U4);
64 generator.Emit(OpCodes.Stind_I4);
73 public object Get(System.Type type)
76 return Enum.ToObject(type, this.val);
79 switch (type.ToString())
82 case "System.UInt32&":
85 throw new ArgumentException("Cannot cast DBus.Type.UInt32 to type '" + type.ToString() + "'");
90 private extern static System.UInt32 dbus_message_iter_get_uint32(IntPtr iter);
93 private extern static bool dbus_message_iter_append_uint32(IntPtr iter, System.UInt32 value);