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

namespace WebKit {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;

#region Autogenerated code
	[StructLayout(LayoutKind.Sequential)]
	public partial struct UserStyleSheet : IEquatable<UserStyleSheet> {


		public static WebKit.UserStyleSheet Zero = new WebKit.UserStyleSheet ();

		public static WebKit.UserStyleSheet New(IntPtr raw) {
			if (raw == IntPtr.Zero)
				return WebKit.UserStyleSheet.Zero;
			return (WebKit.UserStyleSheet) Marshal.PtrToStructure (raw, typeof (WebKit.UserStyleSheet));
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_user_style_sheet_new(IntPtr source, int injected_frames, int level, IntPtr[] allow_list, IntPtr[] block_list);
		static d_webkit_user_style_sheet_new webkit_user_style_sheet_new = FuncLoader.LoadFunction<d_webkit_user_style_sheet_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_user_style_sheet_new"));

		public static UserStyleSheet New(string source, WebKit.UserContentInjectedFrames injected_frames, WebKit.UserStyleLevel level, string[] allow_list, string[] block_list)
		{
			IntPtr native_source = GLib.Marshaller.StringToPtrGStrdup (source);
			int cnt_allow_list = allow_list == null ? 0 : allow_list.Length;
			IntPtr[] native_allow_list = new IntPtr [cnt_allow_list + 1];
			for (int i = 0; i < cnt_allow_list; i++)
				native_allow_list [i] = GLib.Marshaller.StringToPtrGStrdup (allow_list[i]);
			native_allow_list [cnt_allow_list] = IntPtr.Zero;
			int cnt_block_list = block_list == null ? 0 : block_list.Length;
			IntPtr[] native_block_list = new IntPtr [cnt_block_list + 1];
			for (int i = 0; i < cnt_block_list; i++)
				native_block_list [i] = GLib.Marshaller.StringToPtrGStrdup (block_list[i]);
			native_block_list [cnt_block_list] = IntPtr.Zero;
			UserStyleSheet result = UserStyleSheet.New (webkit_user_style_sheet_new(native_source, (int) injected_frames, (int) level, native_allow_list, native_block_list));
			GLib.Marshaller.Free (native_source);
			for (int i = 0; i < native_allow_list.Length - 1; i++) {
				allow_list [i] = GLib.Marshaller.Utf8PtrToString (native_allow_list[i]);
				GLib.Marshaller.Free (native_allow_list[i]);
			}
			for (int i = 0; i < native_block_list.Length - 1; i++) {
				block_list [i] = GLib.Marshaller.Utf8PtrToString (native_block_list[i]);
				GLib.Marshaller.Free (native_block_list[i]);
			}
			return result;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_user_style_sheet_new_for_world(IntPtr source, int injected_frames, int level, IntPtr world_name, IntPtr[] allow_list, IntPtr[] block_list);
		static d_webkit_user_style_sheet_new_for_world webkit_user_style_sheet_new_for_world = FuncLoader.LoadFunction<d_webkit_user_style_sheet_new_for_world>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_user_style_sheet_new_for_world"));

		public static UserStyleSheet NewForWorld(string source, WebKit.UserContentInjectedFrames injected_frames, WebKit.UserStyleLevel level, string world_name, string[] allow_list, string[] block_list)
		{
			IntPtr native_source = GLib.Marshaller.StringToPtrGStrdup (source);
			IntPtr native_world_name = GLib.Marshaller.StringToPtrGStrdup (world_name);
			int cnt_allow_list = allow_list == null ? 0 : allow_list.Length;
			IntPtr[] native_allow_list = new IntPtr [cnt_allow_list + 1];
			for (int i = 0; i < cnt_allow_list; i++)
				native_allow_list [i] = GLib.Marshaller.StringToPtrGStrdup (allow_list[i]);
			native_allow_list [cnt_allow_list] = IntPtr.Zero;
			int cnt_block_list = block_list == null ? 0 : block_list.Length;
			IntPtr[] native_block_list = new IntPtr [cnt_block_list + 1];
			for (int i = 0; i < cnt_block_list; i++)
				native_block_list [i] = GLib.Marshaller.StringToPtrGStrdup (block_list[i]);
			native_block_list [cnt_block_list] = IntPtr.Zero;
			UserStyleSheet result = UserStyleSheet.New (webkit_user_style_sheet_new_for_world(native_source, (int) injected_frames, (int) level, native_world_name, native_allow_list, native_block_list));
			GLib.Marshaller.Free (native_source);
			GLib.Marshaller.Free (native_world_name);
			for (int i = 0; i < native_allow_list.Length - 1; i++) {
				allow_list [i] = GLib.Marshaller.Utf8PtrToString (native_allow_list[i]);
				GLib.Marshaller.Free (native_allow_list[i]);
			}
			for (int i = 0; i < native_block_list.Length - 1; i++) {
				block_list [i] = GLib.Marshaller.Utf8PtrToString (native_block_list[i]);
				GLib.Marshaller.Free (native_block_list[i]);
			}
			return result;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_user_style_sheet_get_type();
		static d_webkit_user_style_sheet_get_type webkit_user_style_sheet_get_type = FuncLoader.LoadFunction<d_webkit_user_style_sheet_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_user_style_sheet_get_type"));

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_webkit_user_style_sheet_ref(IntPtr raw);
		static d_webkit_user_style_sheet_ref webkit_user_style_sheet_ref = FuncLoader.LoadFunction<d_webkit_user_style_sheet_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_user_style_sheet_ref"));

		public WebKit.UserStyleSheet Ref() {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<WebKit.UserStyleSheet>());
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr raw_ret = webkit_user_style_sheet_ref(this_as_native);
			WebKit.UserStyleSheet ret = WebKit.UserStyleSheet.New (raw_ret);
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_webkit_user_style_sheet_unref(IntPtr raw);
		static d_webkit_user_style_sheet_unref webkit_user_style_sheet_unref = FuncLoader.LoadFunction<d_webkit_user_style_sheet_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Webkit), "webkit_user_style_sheet_unref"));

		public void Unref() {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<WebKit.UserStyleSheet>());
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			webkit_user_style_sheet_unref(this_as_native);
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
		}

		static void ReadNative (IntPtr native, ref WebKit.UserStyleSheet target)
		{
			target = New (native);
		}

		public bool Equals (UserStyleSheet other)
		{
			return true;
		}

		public override bool Equals (object other)
		{
			return other is UserStyleSheet && Equals ((UserStyleSheet) other);
		}

		public override int GetHashCode ()
		{
			return this.GetType ().FullName.GetHashCode ();
		}

		public static explicit operator GLib.Value (WebKit.UserStyleSheet boxed)
		{
			GLib.Value val = GLib.Value.Empty;
			val.Init (WebKit.UserStyleSheet.GType);
			val.Val = boxed;
			return val;
		}

		public static explicit operator WebKit.UserStyleSheet (GLib.Value val)
		{
			return (WebKit.UserStyleSheet) val.Val;
		}
#endregion
	}
}
