// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace GLib {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;
	using static GLib.AbiStructExtension;

#region Autogenerated code
	public partial class SocketControlMessage : GLib.Object {

		public SocketControlMessage (IntPtr raw) : base(raw) {}

		protected SocketControlMessage() : base(IntPtr.Zero)
		{
			CreateNativeObject (Array.Empty<string> (), Array.Empty<GLib.Value> ());
		}

		static GetSizeNativeDelegate GetSize_cb_delegate;
		static GetSizeNativeDelegate GetSizeVMCallback {
			get {
				if (GetSize_cb_delegate == null)
					GetSize_cb_delegate = new GetSizeNativeDelegate (GetSize_cb);
				return GetSize_cb_delegate;
			}
		}

		static void OverrideGetSize (GLib.GType gtype)
		{
			OverrideGetSize (gtype, GetSizeVMCallback);
		}

		static void OverrideGetSize (GLib.GType gtype, GetSizeNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_size"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate UIntPtr GetSizeNativeDelegate (IntPtr inst);

		static UIntPtr GetSize_cb (IntPtr inst)
		{
			try {
				SocketControlMessage __obj = GLib.Object.GetObject (inst, false) as SocketControlMessage;
				ulong __result;
				__result = __obj.OnGetSize ();
				return new UIntPtr (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketControlMessage), ConnectionMethod="OverrideGetSize")]
		protected virtual ulong OnGetSize ()
		{
			return InternalGetSize ();
		}

		private ulong InternalGetSize ()
		{
			GetSizeNativeDelegate unmanaged = class_abi.BaseOverride<GetSizeNativeDelegate>(this.LookupGType(), "get_size");
			if (unmanaged == null) return 0;

			UIntPtr __result = unmanaged (this.Handle);
			return (ulong) __result;
		}

		static GetLevelNativeDelegate GetLevel_cb_delegate;
		static GetLevelNativeDelegate GetLevelVMCallback {
			get {
				if (GetLevel_cb_delegate == null)
					GetLevel_cb_delegate = new GetLevelNativeDelegate (GetLevel_cb);
				return GetLevel_cb_delegate;
			}
		}

		static void OverrideGetLevel (GLib.GType gtype)
		{
			OverrideGetLevel (gtype, GetLevelVMCallback);
		}

		static void OverrideGetLevel (GLib.GType gtype, GetLevelNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_level"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int GetLevelNativeDelegate (IntPtr inst);

		static int GetLevel_cb (IntPtr inst)
		{
			try {
				SocketControlMessage __obj = GLib.Object.GetObject (inst, false) as SocketControlMessage;
				int __result;
				__result = __obj.OnGetLevel ();
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketControlMessage), ConnectionMethod="OverrideGetLevel")]
		protected virtual int OnGetLevel ()
		{
			return InternalGetLevel ();
		}

		private int InternalGetLevel ()
		{
			GetLevelNativeDelegate unmanaged = class_abi.BaseOverride<GetLevelNativeDelegate>(this.LookupGType(), "get_level");
			if (unmanaged == null) return 0;

			int __result = unmanaged (this.Handle);
			return __result;
		}

		static GetTypeNativeDelegate GetType_cb_delegate;
		static GetTypeNativeDelegate GetTypeVMCallback {
			get {
				if (GetType_cb_delegate == null)
					GetType_cb_delegate = new GetTypeNativeDelegate (GetType_cb);
				return GetType_cb_delegate;
			}
		}

		static void OverrideGetType (GLib.GType gtype)
		{
			OverrideGetType (gtype, GetTypeVMCallback);
		}

		static void OverrideGetType (GLib.GType gtype, GetTypeNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("get_type"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int GetTypeNativeDelegate (IntPtr inst);

		static int GetType_cb (IntPtr inst)
		{
			try {
				SocketControlMessage __obj = GLib.Object.GetObject (inst, false) as SocketControlMessage;
				int __result;
				__result = __obj.OnGetType ();
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketControlMessage), ConnectionMethod="OverrideGetType")]
		protected virtual int OnGetType ()
		{
			return InternalGetType ();
		}

		private int InternalGetType ()
		{
			GetTypeNativeDelegate unmanaged = class_abi.BaseOverride<GetTypeNativeDelegate>(this.LookupGType(), "get_type");
			if (unmanaged == null) return 0;

			int __result = unmanaged (this.Handle);
			return __result;
		}

		static SerializeNativeDelegate Serialize_cb_delegate;
		static SerializeNativeDelegate SerializeVMCallback {
			get {
				if (Serialize_cb_delegate == null)
					Serialize_cb_delegate = new SerializeNativeDelegate (Serialize_cb);
				return Serialize_cb_delegate;
			}
		}

		static void OverrideSerialize (GLib.GType gtype)
		{
			OverrideSerialize (gtype, SerializeVMCallback);
		}

		static void OverrideSerialize (GLib.GType gtype, SerializeNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("serialize"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate(callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SerializeNativeDelegate (IntPtr inst, IntPtr data);

		static void Serialize_cb (IntPtr inst, IntPtr data)
		{
			try {
				SocketControlMessage __obj = GLib.Object.GetObject (inst, false) as SocketControlMessage;
				__obj.OnSerialize (data);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.SocketControlMessage), ConnectionMethod="OverrideSerialize")]
		protected virtual void OnSerialize (IntPtr data)
		{
			InternalSerialize (data);
		}

		private void InternalSerialize (IntPtr data)
		{
			SerializeNativeDelegate unmanaged = class_abi.BaseOverride<SerializeNativeDelegate>(this.LookupGType(), "serialize");
			if (unmanaged == null) return;

			unmanaged (this.Handle, data);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public unsafe new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("get_size"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // get_size
							, null
							, "get_level"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("get_level"
							, -1
							, (uint) sizeof( IntPtr ) // get_level
							, "get_size"
							, "get_type"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("get_type"
							, -1
							, (uint) sizeof( IntPtr ) // get_type
							, "get_level"
							, "serialize"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("serialize"
							, -1
							, (uint) sizeof( IntPtr ) // serialize
							, "get_type"
							, "deserialize"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("deserialize"
							, -1
							, (uint) sizeof( IntPtr ) // deserialize
							, "serialize"
							, "_g_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved1
							, "deserialize"
							, "_g_reserved2"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved2"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved2
							, "_g_reserved1"
							, "_g_reserved3"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved3"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved3
							, "_g_reserved2"
							, "_g_reserved4"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved4"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved4
							, "_g_reserved3"
							, "_g_reserved5"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved5"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved5
							, "_g_reserved4"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_control_message_deserialize(int level, int type, UIntPtr size, IntPtr data);
		static d_g_socket_control_message_deserialize g_socket_control_message_deserialize = FuncLoader.LoadFunction<d_g_socket_control_message_deserialize>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_control_message_deserialize"));

		public static GLib.SocketControlMessage Deserialize(int level, int type, ulong size, IntPtr data) {
			IntPtr raw_ret = g_socket_control_message_deserialize(level, type, new UIntPtr (size), data);
			GLib.SocketControlMessage ret = GLib.Object.GetObject(raw_ret) as GLib.SocketControlMessage;
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_g_socket_control_message_get_level(IntPtr raw);
		static d_g_socket_control_message_get_level g_socket_control_message_get_level = FuncLoader.LoadFunction<d_g_socket_control_message_get_level>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_control_message_get_level"));

		public int Level { 
			get {
				int raw_ret = g_socket_control_message_get_level(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int d_g_socket_control_message_get_msg_type(IntPtr raw);
		static d_g_socket_control_message_get_msg_type g_socket_control_message_get_msg_type = FuncLoader.LoadFunction<d_g_socket_control_message_get_msg_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_control_message_get_msg_type"));

		public int MsgType { 
			get {
				int raw_ret = g_socket_control_message_get_msg_type(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate UIntPtr d_g_socket_control_message_get_size(IntPtr raw);
		static d_g_socket_control_message_get_size g_socket_control_message_get_size = FuncLoader.LoadFunction<d_g_socket_control_message_get_size>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_control_message_get_size"));

		public ulong Size { 
			get {
				UIntPtr raw_ret = g_socket_control_message_get_size(Handle);
				ulong ret = (ulong) raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_socket_control_message_get_type();
		static d_g_socket_control_message_get_type g_socket_control_message_get_type = FuncLoader.LoadFunction<d_g_socket_control_message_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_control_message_get_type"));

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = g_socket_control_message_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_socket_control_message_serialize(IntPtr raw, IntPtr data);
		static d_g_socket_control_message_serialize g_socket_control_message_serialize = FuncLoader.LoadFunction<d_g_socket_control_message_serialize>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_socket_control_message_serialize"));

		public void Serialize(IntPtr data) {
			g_socket_control_message_serialize(Handle, data);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public unsafe new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("priv"
							, GLib.Object.abi_info.Fields
							, (uint) sizeof( IntPtr ) // priv
							, null
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
