// 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 OutputStream : GLib.Object {

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

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

		static WriteFnNativeDelegate WriteFn_cb_delegate;
		static WriteFnNativeDelegate WriteFnVMCallback {
			get {
				if (WriteFn_cb_delegate == null)
					WriteFn_cb_delegate = new WriteFnNativeDelegate (WriteFn_cb);
				return WriteFn_cb_delegate;
			}
		}

		static void OverrideWriteFn (GLib.GType gtype)
		{
			OverrideWriteFn (gtype, WriteFnVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr WriteFnNativeDelegate (IntPtr inst, IntPtr buffer, UIntPtr count, IntPtr cancellable, out IntPtr error);

		static IntPtr WriteFn_cb (IntPtr inst, IntPtr buffer, UIntPtr count, IntPtr cancellable, out IntPtr error)
		{
			error = IntPtr.Zero;

			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				long __result;
				__result = __obj.OnWriteFn (buffer, (ulong) count, GLib.Object.GetObject(cancellable) as GLib.Cancellable);
				return new IntPtr (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideWriteFn")]
		protected virtual long OnWriteFn (IntPtr buffer, ulong count, GLib.Cancellable cancellable)
		{
			return InternalWriteFn (buffer, count, cancellable);
		}

		private long InternalWriteFn (IntPtr buffer, ulong count, GLib.Cancellable cancellable)
		{
			WriteFnNativeDelegate unmanaged = class_abi.BaseOverride<WriteFnNativeDelegate>(this.LookupGType(), "write_fn");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr error = IntPtr.Zero;
			IntPtr __result = unmanaged (this.Handle, buffer, new UIntPtr (count), cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			return (long) __result;
		}

		static SpliceNativeDelegate Splice_cb_delegate;
		static SpliceNativeDelegate SpliceVMCallback {
			get {
				if (Splice_cb_delegate == null)
					Splice_cb_delegate = new SpliceNativeDelegate (Splice_cb);
				return Splice_cb_delegate;
			}
		}

		static void OverrideSplice (GLib.GType gtype)
		{
			OverrideSplice (gtype, SpliceVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr SpliceNativeDelegate (IntPtr inst, IntPtr source, int flags, IntPtr cancellable, out IntPtr error);

		static IntPtr Splice_cb (IntPtr inst, IntPtr source, int flags, IntPtr cancellable, out IntPtr error)
		{
			error = IntPtr.Zero;

			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				long __result;
				__result = __obj.OnSplice (GLib.Object.GetObject(source) as GLib.InputStream, (GLib.OutputStreamSpliceFlags) flags, GLib.Object.GetObject(cancellable) as GLib.Cancellable);
				return new IntPtr (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideSplice")]
		protected virtual long OnSplice (GLib.InputStream source, GLib.OutputStreamSpliceFlags flags, GLib.Cancellable cancellable)
		{
			return InternalSplice (source, flags, cancellable);
		}

		private long InternalSplice (GLib.InputStream source, GLib.OutputStreamSpliceFlags flags, GLib.Cancellable cancellable)
		{
			SpliceNativeDelegate unmanaged = class_abi.BaseOverride<SpliceNativeDelegate>(this.LookupGType(), "splice");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr error = IntPtr.Zero;
			IntPtr __result = unmanaged (this.Handle, source == null ? IntPtr.Zero : source.Handle, (int) flags, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			return (long) __result;
		}

		static FlushNativeDelegate Flush_cb_delegate;
		static FlushNativeDelegate FlushVMCallback {
			get {
				if (Flush_cb_delegate == null)
					Flush_cb_delegate = new FlushNativeDelegate (Flush_cb);
				return Flush_cb_delegate;
			}
		}

		static void OverrideFlush (GLib.GType gtype)
		{
			OverrideFlush (gtype, FlushVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool FlushNativeDelegate (IntPtr inst, IntPtr cancellable, out IntPtr error);

		static bool Flush_cb (IntPtr inst, IntPtr cancellable, out IntPtr error)
		{
			error = IntPtr.Zero;

			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				bool __result;
				__result = __obj.OnFlush (GLib.Object.GetObject(cancellable) as GLib.Cancellable);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideFlush")]
		protected virtual bool OnFlush (GLib.Cancellable cancellable)
		{
			return InternalFlush (cancellable);
		}

		private bool InternalFlush (GLib.Cancellable cancellable)
		{
			FlushNativeDelegate unmanaged = class_abi.BaseOverride<FlushNativeDelegate>(this.LookupGType(), "flush");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr error = IntPtr.Zero;
			bool __result = unmanaged (this.Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			return __result;
		}

		static CloseFnNativeDelegate CloseFn_cb_delegate;
		static CloseFnNativeDelegate CloseFnVMCallback {
			get {
				if (CloseFn_cb_delegate == null)
					CloseFn_cb_delegate = new CloseFnNativeDelegate (CloseFn_cb);
				return CloseFn_cb_delegate;
			}
		}

		static void OverrideCloseFn (GLib.GType gtype)
		{
			OverrideCloseFn (gtype, CloseFnVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool CloseFnNativeDelegate (IntPtr inst, IntPtr cancellable, out IntPtr error);

		static bool CloseFn_cb (IntPtr inst, IntPtr cancellable, out IntPtr error)
		{
			error = IntPtr.Zero;

			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				bool __result;
				__result = __obj.OnCloseFn (GLib.Object.GetObject(cancellable) as GLib.Cancellable);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideCloseFn")]
		protected virtual bool OnCloseFn (GLib.Cancellable cancellable)
		{
			return InternalCloseFn (cancellable);
		}

		private bool InternalCloseFn (GLib.Cancellable cancellable)
		{
			CloseFnNativeDelegate unmanaged = class_abi.BaseOverride<CloseFnNativeDelegate>(this.LookupGType(), "close_fn");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr error = IntPtr.Zero;
			bool __result = unmanaged (this.Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			return __result;
		}

		static WriteAsyncNativeDelegate WriteAsync_cb_delegate;
		static WriteAsyncNativeDelegate WriteAsyncVMCallback {
			get {
				if (WriteAsync_cb_delegate == null)
					WriteAsync_cb_delegate = new WriteAsyncNativeDelegate (WriteAsync_cb);
				return WriteAsync_cb_delegate;
			}
		}

		static void OverrideWriteAsync (GLib.GType gtype)
		{
			OverrideWriteAsync (gtype, WriteAsyncVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void WriteAsyncNativeDelegate (IntPtr inst, IntPtr buffer, UIntPtr count, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);

		static void WriteAsync_cb (IntPtr inst, IntPtr buffer, UIntPtr count, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data)
		{
			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				GLibSharp.AsyncReadyCallbackInvoker cb_invoker = new GLibSharp.AsyncReadyCallbackInvoker (cb, user_data);
				__obj.OnWriteAsync (buffer, (ulong) count, io_priority, GLib.Object.GetObject(cancellable) as GLib.Cancellable, cb_invoker.Handler);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideWriteAsync")]
		protected virtual void OnWriteAsync (IntPtr buffer, ulong count, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb)
		{
			InternalWriteAsync (buffer, count, io_priority, cancellable, cb);
		}

		private void InternalWriteAsync (IntPtr buffer, ulong count, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb)
		{
			WriteAsyncNativeDelegate unmanaged = class_abi.BaseOverride<WriteAsyncNativeDelegate>(this.LookupGType(), "write_async");
			if (unmanaged == null) return;

			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			unmanaged (this.Handle, buffer, new UIntPtr (count), io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		static WriteFinishNativeDelegate WriteFinish_cb_delegate;
		static WriteFinishNativeDelegate WriteFinishVMCallback {
			get {
				if (WriteFinish_cb_delegate == null)
					WriteFinish_cb_delegate = new WriteFinishNativeDelegate (WriteFinish_cb);
				return WriteFinish_cb_delegate;
			}
		}

		static void OverrideWriteFinish (GLib.GType gtype)
		{
			OverrideWriteFinish (gtype, WriteFinishVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr WriteFinishNativeDelegate (IntPtr inst, IntPtr result, out IntPtr error);

		static IntPtr WriteFinish_cb (IntPtr inst, IntPtr result, out IntPtr error)
		{
			error = IntPtr.Zero;

			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				long __result;
				__result = __obj.OnWriteFinish (GLib.AsyncResultAdapter.GetObject (result, false));
				return new IntPtr (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideWriteFinish")]
		protected virtual long OnWriteFinish (GLib.IAsyncResult result)
		{
			return InternalWriteFinish (result);
		}

		private long InternalWriteFinish (GLib.IAsyncResult result)
		{
			WriteFinishNativeDelegate unmanaged = class_abi.BaseOverride<WriteFinishNativeDelegate>(this.LookupGType(), "write_finish");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr error = IntPtr.Zero;
			IntPtr __result = unmanaged (this.Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			return (long) __result;
		}

		static SpliceAsyncNativeDelegate SpliceAsync_cb_delegate;
		static SpliceAsyncNativeDelegate SpliceAsyncVMCallback {
			get {
				if (SpliceAsync_cb_delegate == null)
					SpliceAsync_cb_delegate = new SpliceAsyncNativeDelegate (SpliceAsync_cb);
				return SpliceAsync_cb_delegate;
			}
		}

		static void OverrideSpliceAsync (GLib.GType gtype)
		{
			OverrideSpliceAsync (gtype, SpliceAsyncVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SpliceAsyncNativeDelegate (IntPtr inst, IntPtr source, int flags, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);

		static void SpliceAsync_cb (IntPtr inst, IntPtr source, int flags, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data)
		{
			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				GLibSharp.AsyncReadyCallbackInvoker cb_invoker = new GLibSharp.AsyncReadyCallbackInvoker (cb, user_data);
				__obj.OnSpliceAsync (GLib.Object.GetObject(source) as GLib.InputStream, (GLib.OutputStreamSpliceFlags) flags, io_priority, GLib.Object.GetObject(cancellable) as GLib.Cancellable, cb_invoker.Handler);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideSpliceAsync")]
		protected virtual void OnSpliceAsync (GLib.InputStream source, GLib.OutputStreamSpliceFlags flags, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb)
		{
			InternalSpliceAsync (source, flags, io_priority, cancellable, cb);
		}

		private void InternalSpliceAsync (GLib.InputStream source, GLib.OutputStreamSpliceFlags flags, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb)
		{
			SpliceAsyncNativeDelegate unmanaged = class_abi.BaseOverride<SpliceAsyncNativeDelegate>(this.LookupGType(), "splice_async");
			if (unmanaged == null) return;

			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			unmanaged (this.Handle, source == null ? IntPtr.Zero : source.Handle, (int) flags, io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		static SpliceFinishNativeDelegate SpliceFinish_cb_delegate;
		static SpliceFinishNativeDelegate SpliceFinishVMCallback {
			get {
				if (SpliceFinish_cb_delegate == null)
					SpliceFinish_cb_delegate = new SpliceFinishNativeDelegate (SpliceFinish_cb);
				return SpliceFinish_cb_delegate;
			}
		}

		static void OverrideSpliceFinish (GLib.GType gtype)
		{
			OverrideSpliceFinish (gtype, SpliceFinishVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr SpliceFinishNativeDelegate (IntPtr inst, IntPtr result, out IntPtr error);

		static IntPtr SpliceFinish_cb (IntPtr inst, IntPtr result, out IntPtr error)
		{
			error = IntPtr.Zero;

			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				long __result;
				__result = __obj.OnSpliceFinish (GLib.AsyncResultAdapter.GetObject (result, false));
				return new IntPtr (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideSpliceFinish")]
		protected virtual long OnSpliceFinish (GLib.IAsyncResult result)
		{
			return InternalSpliceFinish (result);
		}

		private long InternalSpliceFinish (GLib.IAsyncResult result)
		{
			SpliceFinishNativeDelegate unmanaged = class_abi.BaseOverride<SpliceFinishNativeDelegate>(this.LookupGType(), "splice_finish");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr error = IntPtr.Zero;
			IntPtr __result = unmanaged (this.Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			return (long) __result;
		}

		static FlushAsyncNativeDelegate FlushAsync_cb_delegate;
		static FlushAsyncNativeDelegate FlushAsyncVMCallback {
			get {
				if (FlushAsync_cb_delegate == null)
					FlushAsync_cb_delegate = new FlushAsyncNativeDelegate (FlushAsync_cb);
				return FlushAsync_cb_delegate;
			}
		}

		static void OverrideFlushAsync (GLib.GType gtype)
		{
			OverrideFlushAsync (gtype, FlushAsyncVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void FlushAsyncNativeDelegate (IntPtr inst, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);

		static void FlushAsync_cb (IntPtr inst, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data)
		{
			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				GLibSharp.AsyncReadyCallbackInvoker cb_invoker = new GLibSharp.AsyncReadyCallbackInvoker (cb, user_data);
				__obj.OnFlushAsync (io_priority, GLib.Object.GetObject(cancellable) as GLib.Cancellable, cb_invoker.Handler);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideFlushAsync")]
		protected virtual void OnFlushAsync (int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb)
		{
			InternalFlushAsync (io_priority, cancellable, cb);
		}

		private void InternalFlushAsync (int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb)
		{
			FlushAsyncNativeDelegate unmanaged = class_abi.BaseOverride<FlushAsyncNativeDelegate>(this.LookupGType(), "flush_async");
			if (unmanaged == null) return;

			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			unmanaged (this.Handle, io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		static FlushFinishNativeDelegate FlushFinish_cb_delegate;
		static FlushFinishNativeDelegate FlushFinishVMCallback {
			get {
				if (FlushFinish_cb_delegate == null)
					FlushFinish_cb_delegate = new FlushFinishNativeDelegate (FlushFinish_cb);
				return FlushFinish_cb_delegate;
			}
		}

		static void OverrideFlushFinish (GLib.GType gtype)
		{
			OverrideFlushFinish (gtype, FlushFinishVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool FlushFinishNativeDelegate (IntPtr inst, IntPtr result, out IntPtr error);

		static bool FlushFinish_cb (IntPtr inst, IntPtr result, out IntPtr error)
		{
			error = IntPtr.Zero;

			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				bool __result;
				__result = __obj.OnFlushFinish (GLib.AsyncResultAdapter.GetObject (result, false));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideFlushFinish")]
		protected virtual bool OnFlushFinish (GLib.IAsyncResult result)
		{
			return InternalFlushFinish (result);
		}

		private bool InternalFlushFinish (GLib.IAsyncResult result)
		{
			FlushFinishNativeDelegate unmanaged = class_abi.BaseOverride<FlushFinishNativeDelegate>(this.LookupGType(), "flush_finish");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr error = IntPtr.Zero;
			bool __result = unmanaged (this.Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			return __result;
		}

		static CloseAsyncNativeDelegate CloseAsync_cb_delegate;
		static CloseAsyncNativeDelegate CloseAsyncVMCallback {
			get {
				if (CloseAsync_cb_delegate == null)
					CloseAsync_cb_delegate = new CloseAsyncNativeDelegate (CloseAsync_cb);
				return CloseAsync_cb_delegate;
			}
		}

		static void OverrideCloseAsync (GLib.GType gtype)
		{
			OverrideCloseAsync (gtype, CloseAsyncVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void CloseAsyncNativeDelegate (IntPtr inst, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);

		static void CloseAsync_cb (IntPtr inst, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data)
		{
			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				GLibSharp.AsyncReadyCallbackInvoker cb_invoker = new GLibSharp.AsyncReadyCallbackInvoker (cb, user_data);
				__obj.OnCloseAsync (io_priority, GLib.Object.GetObject(cancellable) as GLib.Cancellable, cb_invoker.Handler);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideCloseAsync")]
		protected virtual void OnCloseAsync (int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb)
		{
			InternalCloseAsync (io_priority, cancellable, cb);
		}

		private void InternalCloseAsync (int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb)
		{
			CloseAsyncNativeDelegate unmanaged = class_abi.BaseOverride<CloseAsyncNativeDelegate>(this.LookupGType(), "close_async");
			if (unmanaged == null) return;

			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			unmanaged (this.Handle, io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		static CloseFinishNativeDelegate CloseFinish_cb_delegate;
		static CloseFinishNativeDelegate CloseFinishVMCallback {
			get {
				if (CloseFinish_cb_delegate == null)
					CloseFinish_cb_delegate = new CloseFinishNativeDelegate (CloseFinish_cb);
				return CloseFinish_cb_delegate;
			}
		}

		static void OverrideCloseFinish (GLib.GType gtype)
		{
			OverrideCloseFinish (gtype, CloseFinishVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool CloseFinishNativeDelegate (IntPtr inst, IntPtr result, out IntPtr error);

		static bool CloseFinish_cb (IntPtr inst, IntPtr result, out IntPtr error)
		{
			error = IntPtr.Zero;

			try {
				OutputStream __obj = GLib.Object.GetObject (inst, false) as OutputStream;
				bool __result;
				__result = __obj.OnCloseFinish (GLib.AsyncResultAdapter.GetObject (result, false));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(GLib.OutputStream), ConnectionMethod="OverrideCloseFinish")]
		protected virtual bool OnCloseFinish (GLib.IAsyncResult result)
		{
			return InternalCloseFinish (result);
		}

		private bool InternalCloseFinish (GLib.IAsyncResult result)
		{
			CloseFinishNativeDelegate unmanaged = class_abi.BaseOverride<CloseFinishNativeDelegate>(this.LookupGType(), "close_finish");
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr error = IntPtr.Zero;
			bool __result = unmanaged (this.Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			return __result;
		}


		// 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("write_fn"
							, GLib.Object.class_abi.Fields
							, (uint) sizeof( IntPtr ) // write_fn
							, null
							, "splice"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("splice"
							, -1
							, (uint) sizeof( IntPtr ) // splice
							, "write_fn"
							, "flush"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("flush"
							, -1
							, (uint) sizeof( IntPtr ) // flush
							, "splice"
							, "close_fn"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("close_fn"
							, -1
							, (uint) sizeof( IntPtr ) // close_fn
							, "flush"
							, "write_async"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("write_async"
							, -1
							, (uint) sizeof( IntPtr ) // write_async
							, "close_fn"
							, "write_finish"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("write_finish"
							, -1
							, (uint) sizeof( IntPtr ) // write_finish
							, "write_async"
							, "splice_async"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("splice_async"
							, -1
							, (uint) sizeof( IntPtr ) // splice_async
							, "write_finish"
							, "splice_finish"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("splice_finish"
							, -1
							, (uint) sizeof( IntPtr ) // splice_finish
							, "splice_async"
							, "flush_async"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("flush_async"
							, -1
							, (uint) sizeof( IntPtr ) // flush_async
							, "splice_finish"
							, "flush_finish"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("flush_finish"
							, -1
							, (uint) sizeof( IntPtr ) // flush_finish
							, "flush_async"
							, "close_async"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("close_async"
							, -1
							, (uint) sizeof( IntPtr ) // close_async
							, "flush_finish"
							, "close_finish"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("close_finish"
							, -1
							, (uint) sizeof( IntPtr ) // close_finish
							, "close_async"
							, "_g_reserved1"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved1"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved1
							, "close_finish"
							, "_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"
							, "_g_reserved6"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved6"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved6
							, "_g_reserved5"
							, "_g_reserved7"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved7"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved7
							, "_g_reserved6"
							, "_g_reserved8"
							, (uint) sizeof(IntPtr)
							, 0
							),
						new GLib.AbiField("_g_reserved8"
							, -1
							, (uint) sizeof( IntPtr ) // _g_reserved8
							, "_g_reserved7"
							, null
							, (uint) sizeof(IntPtr)
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

		public void ClearPending() {
			g_output_stream_clear_pending(Handle);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_output_stream_close(IntPtr raw, IntPtr cancellable, out IntPtr error);
		static d_g_output_stream_close g_output_stream_close = FuncLoader.LoadFunction<d_g_output_stream_close>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_close"));

		public unsafe bool Close(GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_output_stream_close(Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_output_stream_close_async(IntPtr raw, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_output_stream_close_async g_output_stream_close_async = FuncLoader.LoadFunction<d_g_output_stream_close_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_close_async"));

		public void CloseAsync(int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_output_stream_close_async(Handle, io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_output_stream_close_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_output_stream_close_finish g_output_stream_close_finish = FuncLoader.LoadFunction<d_g_output_stream_close_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_close_finish"));

		public unsafe bool CloseFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_output_stream_close_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_output_stream_flush(IntPtr raw, IntPtr cancellable, out IntPtr error);
		static d_g_output_stream_flush g_output_stream_flush = FuncLoader.LoadFunction<d_g_output_stream_flush>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_flush"));

		public unsafe bool Flush(GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_output_stream_flush(Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_output_stream_flush_async(IntPtr raw, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_output_stream_flush_async g_output_stream_flush_async = FuncLoader.LoadFunction<d_g_output_stream_flush_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_flush_async"));

		public void FlushAsync(int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_output_stream_flush_async(Handle, io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_output_stream_flush_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_output_stream_flush_finish g_output_stream_flush_finish = FuncLoader.LoadFunction<d_g_output_stream_flush_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_flush_finish"));

		public unsafe bool FlushFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_output_stream_flush_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

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

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

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

		public bool HasPending { 
			get {
				bool raw_ret = g_output_stream_has_pending(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

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

		public bool IsClosed { 
			get {
				bool raw_ret = g_output_stream_is_closed(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

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

		public bool IsClosing { 
			get {
				bool raw_ret = g_output_stream_is_closing(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_output_stream_set_pending(IntPtr raw, out IntPtr error);
		static d_g_output_stream_set_pending g_output_stream_set_pending = FuncLoader.LoadFunction<d_g_output_stream_set_pending>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_set_pending"));

		public unsafe bool SetPending() {
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_output_stream_set_pending(Handle, out error);
			bool ret = raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_output_stream_splice(IntPtr raw, IntPtr source, int flags, IntPtr cancellable, out IntPtr error);
		static d_g_output_stream_splice g_output_stream_splice = FuncLoader.LoadFunction<d_g_output_stream_splice>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_splice"));

		public unsafe long Splice(GLib.InputStream source, GLib.OutputStreamSpliceFlags flags, GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_output_stream_splice(Handle, source == null ? IntPtr.Zero : source.Handle, (int) flags, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			long ret = (long) raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_output_stream_splice_async(IntPtr raw, IntPtr source, int flags, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_output_stream_splice_async g_output_stream_splice_async = FuncLoader.LoadFunction<d_g_output_stream_splice_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_splice_async"));

		public void SpliceAsync(GLib.InputStream source, GLib.OutputStreamSpliceFlags flags, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_output_stream_splice_async(Handle, source == null ? IntPtr.Zero : source.Handle, (int) flags, io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_output_stream_splice_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_output_stream_splice_finish g_output_stream_splice_finish = FuncLoader.LoadFunction<d_g_output_stream_splice_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_splice_finish"));

		public unsafe long SpliceFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_output_stream_splice_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			long ret = (long) raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_output_stream_write(IntPtr raw, byte[] buffer, UIntPtr count, IntPtr cancellable, out IntPtr error);
		static d_g_output_stream_write g_output_stream_write = FuncLoader.LoadFunction<d_g_output_stream_write>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write"));

		public unsafe long Write(byte[] buffer, ulong count, GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_output_stream_write(Handle, buffer, new UIntPtr (count), cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			long ret = (long) raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_output_stream_write_all(IntPtr raw, byte[] buffer, UIntPtr count, out UIntPtr bytes_written, IntPtr cancellable, out IntPtr error);
		static d_g_output_stream_write_all g_output_stream_write_all = FuncLoader.LoadFunction<d_g_output_stream_write_all>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write_all"));

		public unsafe bool WriteAll(byte[] buffer, ulong count, out ulong bytes_written, GLib.Cancellable cancellable) {
			UIntPtr native_bytes_written;
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_output_stream_write_all(Handle, buffer, new UIntPtr (count), out native_bytes_written, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			bool ret = raw_ret;
			bytes_written = (ulong) native_bytes_written;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_output_stream_write_all_async(IntPtr raw, IntPtr buffer, UIntPtr count, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_output_stream_write_all_async g_output_stream_write_all_async = FuncLoader.LoadFunction<d_g_output_stream_write_all_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write_all_async"));

		public void WriteAllAsync(IntPtr buffer, ulong count, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_output_stream_write_all_async(Handle, buffer, new UIntPtr (count), io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool d_g_output_stream_write_all_finish(IntPtr raw, IntPtr result, out UIntPtr bytes_written, out IntPtr error);
		static d_g_output_stream_write_all_finish g_output_stream_write_all_finish = FuncLoader.LoadFunction<d_g_output_stream_write_all_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write_all_finish"));

		public unsafe bool WriteAllFinish(GLib.IAsyncResult result, out ulong bytes_written) {
			UIntPtr native_bytes_written;
			IntPtr error = IntPtr.Zero;
			bool raw_ret = g_output_stream_write_all_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out native_bytes_written, out error);
			bool ret = raw_ret;
			bytes_written = (ulong) native_bytes_written;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_output_stream_write_async(IntPtr raw, byte[] buffer, UIntPtr count, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_output_stream_write_async g_output_stream_write_async = FuncLoader.LoadFunction<d_g_output_stream_write_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write_async"));

		public void WriteAsync(byte[] buffer, ulong count, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_output_stream_write_async(Handle, buffer, new UIntPtr (count), io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_output_stream_write_bytes(IntPtr raw, IntPtr bytes, IntPtr cancellable, out IntPtr error);
		static d_g_output_stream_write_bytes g_output_stream_write_bytes = FuncLoader.LoadFunction<d_g_output_stream_write_bytes>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write_bytes"));

		public unsafe long WriteBytes(GLib.Bytes bytes, GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_output_stream_write_bytes(Handle, bytes == null ? IntPtr.Zero : bytes.Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			long ret = (long) raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void d_g_output_stream_write_bytes_async(IntPtr raw, IntPtr bytes, int io_priority, IntPtr cancellable, GLibSharp.AsyncReadyCallbackNative cb, IntPtr user_data);
		static d_g_output_stream_write_bytes_async g_output_stream_write_bytes_async = FuncLoader.LoadFunction<d_g_output_stream_write_bytes_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write_bytes_async"));

		public void WriteBytesAsync(GLib.Bytes bytes, int io_priority, GLib.Cancellable cancellable, GLib.AsyncReadyCallback cb) {
			GLibSharp.AsyncReadyCallbackWrapper cb_wrapper = new GLibSharp.AsyncReadyCallbackWrapper (cb);
			cb_wrapper.PersistUntilCalled ();
			g_output_stream_write_bytes_async(Handle, bytes == null ? IntPtr.Zero : bytes.Handle, io_priority, cancellable == null ? IntPtr.Zero : cancellable.Handle, cb_wrapper.NativeDelegate, IntPtr.Zero);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_output_stream_write_bytes_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_output_stream_write_bytes_finish g_output_stream_write_bytes_finish = FuncLoader.LoadFunction<d_g_output_stream_write_bytes_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write_bytes_finish"));

		public unsafe long WriteBytesFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_output_stream_write_bytes_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			long ret = (long) raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr d_g_output_stream_write_finish(IntPtr raw, IntPtr result, out IntPtr error);
		static d_g_output_stream_write_finish g_output_stream_write_finish = FuncLoader.LoadFunction<d_g_output_stream_write_finish>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gio), "g_output_stream_write_finish"));

		public unsafe long WriteFinish(GLib.IAsyncResult result) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = g_output_stream_write_finish(Handle, result == null ? IntPtr.Zero : ((result is GLib.Object) ? (result as GLib.Object).Handle : (result as GLib.AsyncResultAdapter).Handle), out error);
			long ret = (long) raw_ret;
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}


		// 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
	}
}
