2 using System.Runtime.InteropServices;
3 using System.Reflection.Emit;
7 namespace DBus.DBusType
12 public class Byte : IDBusType
14 public const char Code = 'y';
15 private System.Byte val;
21 public Byte(System.Byte val, Service service)
26 public Byte(IntPtr iter, Service service)
28 this.val = dbus_message_iter_get_byte(iter);
31 public void Append(IntPtr iter)
33 if (!dbus_message_iter_append_byte(iter, val))
34 throw new ApplicationException("Failed to append BYTE argument:" + val);
37 public static bool Suits(System.Type type)
39 switch (type.ToString()) {
48 public static void EmitMarshalIn(ILGenerator generator, Type type)
51 generator.Emit(OpCodes.Ldind_U1);
55 public static void EmitMarshalOut(ILGenerator generator, Type type, bool isReturn)
57 generator.Emit(OpCodes.Unbox, type);
58 generator.Emit(OpCodes.Ldind_U1);
60 generator.Emit(OpCodes.Stind_I1);
69 public object Get(System.Type type)
71 switch (type.ToString()) {
76 throw new ArgumentException("Cannot cast DBus.Type.Byte to type '" + type.ToString() + "'");
81 private extern static System.Byte dbus_message_iter_get_byte(IntPtr iter);
84 private extern static bool dbus_message_iter_append_byte(IntPtr iter, System.Byte value);