2
using System.Runtime.InteropServices;
3
using System.Reflection.Emit;
7
namespace DBus.DBusType
12
public class Int16 : IDBusType
14
public const char Code = 'n';
15
private System.Int16 val;
21
public Int16(System.Int16 val, Service service)
26
public Int16(IntPtr iter, Service service)
28
dbus_message_iter_get_basic (iter, out this.val);
31
public void Append(IntPtr iter)
33
if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
34
throw new ApplicationException("Failed to append INT16 argument:" + val);
37
public static bool Suits(System.Type type)
39
if (type.IsEnum && Enum.GetUnderlyingType (type) == typeof(System.Int16)) {
43
switch (type.ToString()) {
51
public static void EmitMarshalIn(ILGenerator generator, Type type)
54
generator.Emit(OpCodes.Ldind_I2);
58
public static void EmitMarshalOut(ILGenerator generator, Type type, bool isReturn)
60
generator.Emit(OpCodes.Unbox, type);
61
generator.Emit(OpCodes.Ldind_I2);
63
generator.Emit(OpCodes.Stind_I2);
72
public object Get(System.Type type)
75
return Enum.ToObject(type, this.val);
78
switch (type.ToString()) {
83
throw new ArgumentException("Cannot cast DBus.Type.Int16 to type '" + type.ToString() + "'");
88
private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.Int16 value);
91
private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.Int16 value);