no more submodule

This commit is contained in:
2024-09-15 22:40:48 +02:00
parent df3b8a3135
commit 0234b33671
5804 changed files with 943618 additions and 1 deletions

View File

@@ -0,0 +1,177 @@
// AbiField.cs - Utility to handle complex C structure ABI.
//
// Authors: Thibault Saunier <thibault.saunier@osg.samsung.com>
//
// Copyright (c) 2017 Thibault Saunier
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
// Helper utility to build C structure ABI even when using complex
// packing with union and bit fields. It basically uses the same
// logic as what is done inside csharp implementation (marshal.c in
// the mono codebase) but handling more things.
namespace GLib {
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Linq;
using System.Collections.Specialized;
using System.CodeDom.Compiler;
public class AbiField {
public string Prev_name;
public string Next_name;
public string Name;
public long Offset;
public long Align;
public uint Natural_size;
public AbiStruct container;
public OrderedDictionary Parent_fields; // field_name<string> -> AbiField<> dictionary.
List<List<string>> Union_fields;
long End;
long Size;
public uint Bits;
public AbiField(string name,
long offset,
uint natural_size,
string prev_fieldname,
string next_fieldname,
long align,
uint bits)
{
Name = name;
Offset = offset;
Natural_size = natural_size;
Prev_name = prev_fieldname;
Next_name = next_fieldname;
End = -1;
Size = -1;
Union_fields = null;
Align = (long) align;
Bits = bits;
if (Bits > 0) {
var nbytes = (uint) (Math.Ceiling((double) Bits / (double) 8));
if (nbytes < GetSize())
Align = 1;
else // Like if no bitfields were used.
Bits = 0;
}
}
public AbiField(string name,
OrderedDictionary parent_fields,
uint natural_size,
string prev_fieldname,
string next_fieldname,
long align,
uint bits): this (name, -1,
natural_size, prev_fieldname, next_fieldname, align, bits)
{
Parent_fields = parent_fields;
}
public AbiField(string name,
long offset,
List<List<string>> fields_lists,
string prev_fieldname,
string next_fieldname, uint bits): this(name,
offset, (uint) 0, prev_fieldname, next_fieldname,
-1, bits)
{
Union_fields = fields_lists;
}
public uint GetEnd() {
if (End == -1)
End = (long) GetOffset() + GetSize();
return (uint) End;
}
public uint GetOffset() {
return (uint) Offset;
}
public bool InUnion () {
return Name.Contains(".");
}
public uint GetAlign () {
if (Union_fields != null) {
uint align = 1;
foreach (var fieldnames in Union_fields) {
foreach (var fieldname in fieldnames) {
var field = (AbiField) container.Fields[fieldname];
align = Math.Max(align, field.GetAlign());
}
}
return align;
}
return (uint) Align;
}
public uint GetUnionSize() {
uint size = 0;
foreach (var fieldnames in Union_fields) {
foreach (var fieldname in fieldnames) {
var field = ((AbiField) container.Fields[fieldname]);
var align = field.GetAlign();
if (field.Prev_name != null) {
var prev = ((AbiField)container.Fields[field.Prev_name]);
if (!prev.InUnion())
field.Offset = Offset;
else
field.Offset = prev.GetEnd();
}
field.Offset += align - 1;
field.Offset &= ~(align - 1);
size = Math.Max(size, field.GetEnd() - (uint) Offset);
}
}
return size;
}
public uint GetSize() {
if (Size != -1)
return (uint) Size;
if (Union_fields != null) {
Size = GetUnionSize();
} else {
Size = Natural_size;
}
return (uint) Size;
}
}
}

View File

@@ -0,0 +1,145 @@
// AbiField.cs - Utility to handle complex C structure ABI.
//
// Authors: Thibault Saunier <thibault.saunier@osg.samsung.com>
//
// Copyright (c) 2017 Thibault Saunier
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
// Helper utility to build C structure ABI even when using complex
// packing with union and bit fields. It basically uses the same
// logic as what is done inside csharp implementation (marshal.c in
// the mono codebase) but handling more things.
namespace GLib {
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Linq;
using System.Collections.Specialized;
using System.CodeDom.Compiler;
public class AbiStruct {
public OrderedDictionary Fields = null;
public AbiStruct(OrderedDictionary fields) {
Fields = fields;
}
public AbiStruct(List<GLib.AbiField> fields) {
Fields = new OrderedDictionary();
foreach (var field in fields)
Fields[field.Name] = field;
Load();
}
static uint GetMinAlign(OrderedDictionary fields) {
uint align = 1;
for (var i = 0; i < fields.Count; i++) {
var field = ((GLib.AbiField) fields[i]);
if (field.Parent_fields != null) {
align = Math.Max(align, GetMinAlign(field.Parent_fields));
}
align = Math.Max(align, field.GetAlign());
}
return align;
}
public uint Align {
get {
return GetMinAlign(Fields);
}
}
void Load () {
long bitfields_offset = -1;
long bitfields_size = -1;
for (var i = 0; i < Fields.Count; i++ ) {
var field = (AbiField) Fields[i];
field.container = this;
var align = field.GetAlign();
if (field.InUnion())
continue;
if (field.Prev_name != null) {
field.Offset = ((AbiField)Fields[field.Prev_name]).GetEnd();
} else if (field.Parent_fields != null) {
field.Offset = GetStructureSize(field.Parent_fields);
}
field.Offset += align - 1;
field.Offset &= ~(align - 1);
if (field.Bits > 0) {
// Pack all following bitfields into the same area.
if (bitfields_offset == -1) {
uint nbits = 0;
bitfields_offset = field.Offset;
for (var j = i + 1; j < Fields.Count; j++ ) {
var nfield = (AbiField) Fields[j];
if (nfield.Bits > 0)
nbits += nfield.Bits;
}
bitfields_size = (long) (Math.Ceiling((double) field.Bits / (double) 8));
}
field.Offset = (uint) bitfields_offset;
field.Natural_size = (uint) bitfields_size;
} else {
bitfields_offset = bitfields_size = -1;
}
}
}
public uint GetFieldOffset(string field) {
return ((AbiField) Fields[field]).GetOffset();
}
static uint GetStructureSize(OrderedDictionary fields) {
uint size = 0;
uint min_align = GetMinAlign(fields);
for (var i = 0; i < fields.Count; i++) {
var field = ((GLib.AbiField) fields[i]);
if (field.InUnion())
continue;
var tsize = (uint) (Math.Ceiling((double) (field.GetEnd() / (double) min_align)) * (double) min_align);
size = Math.Max(tsize, size);
}
return size;
}
public uint Size {
get {
return GetStructureSize(Fields);
}
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Runtime.InteropServices;
namespace GLib
{
public static class AbiStructExtension
{
public static N BaseOverride<N>(this AbiStruct class_abi, GType gtype, string fieldname) where N : Delegate
{
N unmanaged = null;
unsafe {
IntPtr raw_ptr = IntPtr.Zero;
while (raw_ptr == IntPtr.Zero && GType.IsManaged(gtype)) {
gtype = gtype.GetThresholdType();
var abi_ptr = (IntPtr*) (((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset(fieldname));
raw_ptr = *abi_ptr;
}
if (raw_ptr != IntPtr.Zero) {
unmanaged = Marshal.GetDelegateForFunctionPointer<N>(raw_ptr);
}
}
return unmanaged;
}
}
}

View File

@@ -0,0 +1,81 @@
// GLib.Argv.cs : Argv marshaling class
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class Argv {
IntPtr[] arg_ptrs;
IntPtr handle;
bool add_progname = false;
~Argv ()
{
Marshaller.Free (arg_ptrs);
Marshaller.Free (handle);
}
public Argv (string[] args) : this (args, false) {}
public Argv (string[] args, bool add_program_name)
{
add_progname = add_program_name;
if (add_progname) {
string[] full = new string [args.Length + 1];
full [0] = System.Environment.GetCommandLineArgs ()[0];
args.CopyTo (full, 1);
args = full;
}
arg_ptrs = new IntPtr [args.Length];
for (int i = 0; i < args.Length; i++)
arg_ptrs [i] = Marshaller.StringToPtrGStrdup (args[i]);
handle = Marshaller.Malloc ((ulong)(IntPtr.Size * args.Length));
for (int i = 0; i < args.Length; i++)
Marshal.WriteIntPtr (handle, i * IntPtr.Size, arg_ptrs [i]);
}
public IntPtr Handle {
get {
return handle;
}
}
public string[] GetArgs (int argc)
{
int count = add_progname ? argc - 1 : argc;
int idx = add_progname ? 1 : 0;
string[] result = new string [count];
for (int i = 0; i < count; i++, idx++)
result [i] = Marshaller.Utf8PtrToString (Marshal.ReadIntPtr (handle, idx * IntPtr.Size));
return result;
}
}
}

View File

@@ -0,0 +1,175 @@
// Bytes.cs - Bytes class implementation
//
// Author: Stephan Sundermann <stephansundermann@gmail.com>
//
// Copyright (c) 2014 Stephan Sundermann
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public partial class Bytes : GLib.Opaque, IComparable<Bytes>, IEquatable<Bytes>
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_bytes_get_type();
static d_g_bytes_get_type g_bytes_get_type = FuncLoader.LoadFunction<d_g_bytes_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_get_type"));
public static GLib.GType GType {
get {
IntPtr raw_ret = g_bytes_get_type ();
GLib.GType ret = new GLib.GType (raw_ret);
return ret;
}
}
public Bytes (IntPtr raw) : base (raw) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_bytes_new(byte [] data, UIntPtr size);
static d_g_bytes_new g_bytes_new = FuncLoader.LoadFunction<d_g_bytes_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_new"));
public Bytes (byte [] data)
{
Raw = g_bytes_new (data, new UIntPtr ((ulong)data.Length));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_bytes_new_from_bytes(IntPtr raw, UIntPtr offset, UIntPtr length);
static d_g_bytes_new_from_bytes g_bytes_new_from_bytes = FuncLoader.LoadFunction<d_g_bytes_new_from_bytes>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_new_from_bytes"));
public Bytes (Bytes bytes, ulong offset, ulong length)
{
Raw = g_bytes_new_from_bytes (bytes.Handle, new UIntPtr (offset), new UIntPtr (length));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_bytes_new_take(byte [] data, UIntPtr size);
static d_g_bytes_new_take g_bytes_new_take = FuncLoader.LoadFunction<d_g_bytes_new_take>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_new_take"));
public static Bytes NewTake (byte [] data)
{
return new Bytes (g_bytes_new_take (data, new UIntPtr ((ulong)data.Length)));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_bytes_new_static(byte [] data, UIntPtr size);
static d_g_bytes_new_static g_bytes_new_static = FuncLoader.LoadFunction<d_g_bytes_new_static>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_new_static"));
public static Bytes NewStatic (byte [] data)
{
return new Bytes (g_bytes_new_static (data, new UIntPtr ((ulong)data.Length)));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_bytes_compare(IntPtr raw, IntPtr bytes);
static d_g_bytes_compare g_bytes_compare = FuncLoader.LoadFunction<d_g_bytes_compare>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_compare"));
public int CompareTo (Bytes bytes)
{
return g_bytes_compare (Handle, bytes.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_bytes_equal(IntPtr raw, IntPtr bytes2);
static d_g_bytes_equal g_bytes_equal = FuncLoader.LoadFunction<d_g_bytes_equal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_equal"));
public bool Equals (Bytes other)
{
return g_bytes_equal (Handle, other.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate UIntPtr d_g_bytes_get_size(IntPtr raw);
static d_g_bytes_get_size g_bytes_get_size = FuncLoader.LoadFunction<d_g_bytes_get_size>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_get_size"));
public ulong Size {
get {
return (ulong) g_bytes_get_size (Handle);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_bytes_hash(IntPtr raw);
static d_g_bytes_hash g_bytes_hash = FuncLoader.LoadFunction<d_g_bytes_hash>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_hash"));
public uint GetHash ()
{
return g_bytes_hash (Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_bytes_get_data(IntPtr raw, out UIntPtr size);
static d_g_bytes_get_data g_bytes_get_data = FuncLoader.LoadFunction<d_g_bytes_get_data>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_get_data"));
public byte [] Data {
get {
UIntPtr size;
IntPtr ptr = g_bytes_get_data (Handle, out size);
if (ptr == IntPtr.Zero)
return null;
int sz = (int) size;
byte [] bytes = new byte [sz];
Marshal.Copy (ptr, bytes, 0, sz);
return bytes;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_bytes_ref(IntPtr raw);
static d_g_bytes_ref g_bytes_ref = FuncLoader.LoadFunction<d_g_bytes_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_ref"));
protected override void Ref (IntPtr raw)
{
if (!Owned) {
g_bytes_ref (raw);
Owned = true;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_bytes_unref(IntPtr raw);
static d_g_bytes_unref g_bytes_unref = FuncLoader.LoadFunction<d_g_bytes_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_bytes_unref"));
protected override void Unref (IntPtr raw)
{
if (Owned) {
g_bytes_unref (raw);
Owned = false;
}
}
class FinalizerInfo
{
IntPtr handle;
public FinalizerInfo (IntPtr handle)
{
this.handle = handle;
}
public bool Handler ()
{
g_bytes_unref (handle);
return false;
}
}
~Bytes ()
{
if (!Owned)
return;
FinalizerInfo info = new FinalizerInfo (Handle);
GLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));
}
}
}

View File

@@ -0,0 +1,68 @@
// 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;
#region Autogenerated code
public partial class Cond : GLib.Opaque {
public struct ABI {
IntPtr p;
int i1;
int i2;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_cond_broadcast(IntPtr raw);
static d_g_cond_broadcast g_cond_broadcast = FuncLoader.LoadFunction<d_g_cond_broadcast>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_cond_broadcast"));
public void Broadcast() {
g_cond_broadcast(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_cond_clear(IntPtr raw);
static d_g_cond_clear g_cond_clear = FuncLoader.LoadFunction<d_g_cond_clear>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_cond_clear"));
public void Clear() {
g_cond_clear(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_cond_init(IntPtr raw);
static d_g_cond_init g_cond_init = FuncLoader.LoadFunction<d_g_cond_init>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_cond_init"));
public void Init() {
g_cond_init(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_cond_signal(IntPtr raw);
static d_g_cond_signal g_cond_signal = FuncLoader.LoadFunction<d_g_cond_signal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_cond_signal"));
public void Signal() {
g_cond_signal(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_cond_wait(IntPtr raw, IntPtr mutex);
static d_g_cond_wait g_cond_wait = FuncLoader.LoadFunction<d_g_cond_wait>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_cond_wait"));
public void Wait(GLib.Mutex mutex) {
g_cond_wait(Handle, mutex == null ? IntPtr.Zero : mutex.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_cond_wait_until(IntPtr raw, IntPtr mutex, long end_time);
static d_g_cond_wait_until g_cond_wait_until = FuncLoader.LoadFunction<d_g_cond_wait_until>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_cond_wait_until"));
public bool WaitUntil(GLib.Mutex mutex, long end_time) {
bool raw_ret = g_cond_wait_until(Handle, mutex == null ? IntPtr.Zero : mutex.Handle, end_time);
bool ret = raw_ret;
return ret;
}
public Cond(IntPtr raw) : base(raw) {}
#endregion
}
}

View File

@@ -0,0 +1,30 @@
// ConnectBeforeAttribute.cs
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
public sealed class ConnectBeforeAttribute : Attribute
{
public ConnectBeforeAttribute () {}
}
}

View File

@@ -0,0 +1,479 @@
// 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;
#region Autogenerated code
public partial class Date : GLib.Opaque {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_get_type();
static d_g_date_get_type g_date_get_type = FuncLoader.LoadFunction<d_g_date_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_type"));
public static GLib.GType GType {
get {
IntPtr raw_ret = g_date_get_type();
GLib.GType ret = new GLib.GType(raw_ret);
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_add_days(IntPtr raw, uint n_days);
static d_g_date_add_days g_date_add_days = FuncLoader.LoadFunction<d_g_date_add_days>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_add_days"));
public void AddDays(uint n_days) {
g_date_add_days(Handle, n_days);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_add_months(IntPtr raw, uint n_months);
static d_g_date_add_months g_date_add_months = FuncLoader.LoadFunction<d_g_date_add_months>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_add_months"));
public void AddMonths(uint n_months) {
g_date_add_months(Handle, n_months);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_add_years(IntPtr raw, uint n_years);
static d_g_date_add_years g_date_add_years = FuncLoader.LoadFunction<d_g_date_add_years>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_add_years"));
public void AddYears(uint n_years) {
g_date_add_years(Handle, n_years);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_clamp(IntPtr raw, IntPtr min_date, IntPtr max_date);
static d_g_date_clamp g_date_clamp = FuncLoader.LoadFunction<d_g_date_clamp>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_clamp"));
public void Clamp(GLib.Date min_date, GLib.Date max_date) {
g_date_clamp(Handle, min_date == null ? IntPtr.Zero : min_date.Handle, max_date == null ? IntPtr.Zero : max_date.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_clear(IntPtr raw, uint n_dates);
static d_g_date_clear g_date_clear = FuncLoader.LoadFunction<d_g_date_clear>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_clear"));
public void Clear(uint n_dates) {
g_date_clear(Handle, n_dates);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_compare(IntPtr raw, IntPtr rhs);
static d_g_date_compare g_date_compare = FuncLoader.LoadFunction<d_g_date_compare>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_compare"));
public int Compare(GLib.Date rhs) {
int raw_ret = g_date_compare(Handle, rhs == null ? IntPtr.Zero : rhs.Handle);
int ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_days_between(IntPtr raw, IntPtr date2);
static d_g_date_days_between g_date_days_between = FuncLoader.LoadFunction<d_g_date_days_between>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_days_between"));
public int DaysBetween(GLib.Date date2) {
int raw_ret = g_date_days_between(Handle, date2 == null ? IntPtr.Zero : date2.Handle);
int ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate byte d_g_date_get_day(IntPtr raw);
static d_g_date_get_day g_date_get_day = FuncLoader.LoadFunction<d_g_date_get_day>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_day"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_day(IntPtr raw, byte day);
static d_g_date_set_day g_date_set_day = FuncLoader.LoadFunction<d_g_date_set_day>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_day"));
public byte Day {
get {
byte raw_ret = g_date_get_day(Handle);
byte ret = raw_ret;
return ret;
}
set {
g_date_set_day(Handle, value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_date_get_day_of_year(IntPtr raw);
static d_g_date_get_day_of_year g_date_get_day_of_year = FuncLoader.LoadFunction<d_g_date_get_day_of_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_day_of_year"));
public uint DayOfYear {
get {
uint raw_ret = g_date_get_day_of_year(Handle);
uint ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_date_get_iso8601_week_of_year(IntPtr raw);
static d_g_date_get_iso8601_week_of_year g_date_get_iso8601_week_of_year = FuncLoader.LoadFunction<d_g_date_get_iso8601_week_of_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_iso8601_week_of_year"));
public uint Iso8601WeekOfYear {
get {
uint raw_ret = g_date_get_iso8601_week_of_year(Handle);
uint ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_date_get_julian(IntPtr raw);
static d_g_date_get_julian g_date_get_julian = FuncLoader.LoadFunction<d_g_date_get_julian>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_julian"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_julian(IntPtr raw, uint julian_date);
static d_g_date_set_julian g_date_set_julian = FuncLoader.LoadFunction<d_g_date_set_julian>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_julian"));
public uint Julian {
get {
uint raw_ret = g_date_get_julian(Handle);
uint ret = raw_ret;
return ret;
}
set {
g_date_set_julian(Handle, value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_date_get_monday_week_of_year(IntPtr raw);
static d_g_date_get_monday_week_of_year g_date_get_monday_week_of_year = FuncLoader.LoadFunction<d_g_date_get_monday_week_of_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_monday_week_of_year"));
public uint MondayWeekOfYear {
get {
uint raw_ret = g_date_get_monday_week_of_year(Handle);
uint ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_get_month(IntPtr raw);
static d_g_date_get_month g_date_get_month = FuncLoader.LoadFunction<d_g_date_get_month>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_month"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_month(IntPtr raw, int month);
static d_g_date_set_month g_date_set_month = FuncLoader.LoadFunction<d_g_date_set_month>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_month"));
public int Month {
get {
int raw_ret = g_date_get_month(Handle);
int ret = raw_ret;
return ret;
}
set {
g_date_set_month(Handle, value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_date_get_sunday_week_of_year(IntPtr raw);
static d_g_date_get_sunday_week_of_year g_date_get_sunday_week_of_year = FuncLoader.LoadFunction<d_g_date_get_sunday_week_of_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_sunday_week_of_year"));
public uint SundayWeekOfYear {
get {
uint raw_ret = g_date_get_sunday_week_of_year(Handle);
uint ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_get_weekday(IntPtr raw);
static d_g_date_get_weekday g_date_get_weekday = FuncLoader.LoadFunction<d_g_date_get_weekday>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_weekday"));
public int Weekday {
get {
int raw_ret = g_date_get_weekday(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate ushort d_g_date_get_year(IntPtr raw);
static d_g_date_get_year g_date_get_year = FuncLoader.LoadFunction<d_g_date_get_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_year"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_year(IntPtr raw, ushort year);
static d_g_date_set_year g_date_set_year = FuncLoader.LoadFunction<d_g_date_set_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_year"));
public ushort Year {
get {
ushort raw_ret = g_date_get_year(Handle);
ushort ret = raw_ret;
return ret;
}
set {
g_date_set_year(Handle, value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_is_first_of_month(IntPtr raw);
static d_g_date_is_first_of_month g_date_is_first_of_month = FuncLoader.LoadFunction<d_g_date_is_first_of_month>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_is_first_of_month"));
public bool IsFirstOfMonth {
get {
bool raw_ret = g_date_is_first_of_month(Handle);
bool ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_is_last_of_month(IntPtr raw);
static d_g_date_is_last_of_month g_date_is_last_of_month = FuncLoader.LoadFunction<d_g_date_is_last_of_month>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_is_last_of_month"));
public bool IsLastOfMonth {
get {
bool raw_ret = g_date_is_last_of_month(Handle);
bool ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_order(IntPtr raw, IntPtr date2);
static d_g_date_order g_date_order = FuncLoader.LoadFunction<d_g_date_order>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_order"));
public void Order(GLib.Date date2) {
g_date_order(Handle, date2 == null ? IntPtr.Zero : date2.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_dmy(IntPtr raw, byte day, int month, ushort y);
static d_g_date_set_dmy g_date_set_dmy = FuncLoader.LoadFunction<d_g_date_set_dmy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_dmy"));
public void SetDmy(byte day, int month, ushort y) {
g_date_set_dmy(Handle, day, month, y);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_parse(IntPtr raw, IntPtr str);
static d_g_date_set_parse g_date_set_parse = FuncLoader.LoadFunction<d_g_date_set_parse>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_parse"));
public string Parse {
set {
IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
g_date_set_parse(Handle, native_value);
GLib.Marshaller.Free (native_value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_time(IntPtr raw, int time_);
static d_g_date_set_time g_date_set_time = FuncLoader.LoadFunction<d_g_date_set_time>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_time"));
[Obsolete]
public int Time {
set {
g_date_set_time(Handle, value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_time_t(IntPtr raw, IntPtr timet);
static d_g_date_set_time_t g_date_set_time_t = FuncLoader.LoadFunction<d_g_date_set_time_t>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_time_t"));
public long TimeT {
set {
g_date_set_time_t(Handle, new IntPtr (value));
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_set_time_val(IntPtr raw, IntPtr value);
static d_g_date_set_time_val g_date_set_time_val = FuncLoader.LoadFunction<d_g_date_set_time_val>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_set_time_val"));
public GLib.TimeVal TimeVal {
set {
IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
g_date_set_time_val(Handle, native_value);
value = GLib.TimeVal.New (native_value);
Marshal.FreeHGlobal (native_value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_subtract_days(IntPtr raw, uint n_days);
static d_g_date_subtract_days g_date_subtract_days = FuncLoader.LoadFunction<d_g_date_subtract_days>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_subtract_days"));
public void SubtractDays(uint n_days) {
g_date_subtract_days(Handle, n_days);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_subtract_months(IntPtr raw, uint n_months);
static d_g_date_subtract_months g_date_subtract_months = FuncLoader.LoadFunction<d_g_date_subtract_months>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_subtract_months"));
public void SubtractMonths(uint n_months) {
g_date_subtract_months(Handle, n_months);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_subtract_years(IntPtr raw, uint n_years);
static d_g_date_subtract_years g_date_subtract_years = FuncLoader.LoadFunction<d_g_date_subtract_years>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_subtract_years"));
public void SubtractYears(uint n_years) {
g_date_subtract_years(Handle, n_years);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_to_struct_tm(IntPtr raw, IntPtr tm);
static d_g_date_to_struct_tm g_date_to_struct_tm = FuncLoader.LoadFunction<d_g_date_to_struct_tm>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_to_struct_tm"));
public void ToStructTm(IntPtr tm) {
g_date_to_struct_tm(Handle, tm);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_valid(IntPtr raw);
static d_g_date_valid g_date_valid = FuncLoader.LoadFunction<d_g_date_valid>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_valid"));
public bool Valid() {
bool raw_ret = g_date_valid(Handle);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate byte d_g_date_get_days_in_month(int month, ushort year);
static d_g_date_get_days_in_month g_date_get_days_in_month = FuncLoader.LoadFunction<d_g_date_get_days_in_month>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_days_in_month"));
public static byte GetDaysInMonth(int month, ushort year) {
byte raw_ret = g_date_get_days_in_month(month, year);
byte ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate byte d_g_date_get_monday_weeks_in_year(ushort year);
static d_g_date_get_monday_weeks_in_year g_date_get_monday_weeks_in_year = FuncLoader.LoadFunction<d_g_date_get_monday_weeks_in_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_monday_weeks_in_year"));
public static byte GetMondayWeeksInYear(ushort year) {
byte raw_ret = g_date_get_monday_weeks_in_year(year);
byte ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate byte d_g_date_get_sunday_weeks_in_year(ushort year);
static d_g_date_get_sunday_weeks_in_year g_date_get_sunday_weeks_in_year = FuncLoader.LoadFunction<d_g_date_get_sunday_weeks_in_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_get_sunday_weeks_in_year"));
public static byte GetSundayWeeksInYear(ushort year) {
byte raw_ret = g_date_get_sunday_weeks_in_year(year);
byte ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_is_leap_year(ushort year);
static d_g_date_is_leap_year g_date_is_leap_year = FuncLoader.LoadFunction<d_g_date_is_leap_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_is_leap_year"));
public static bool IsLeapYear(ushort year) {
bool raw_ret = g_date_is_leap_year(year);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate UIntPtr d_g_date_strftime(IntPtr s, UIntPtr slen, IntPtr format, IntPtr date);
static d_g_date_strftime g_date_strftime = FuncLoader.LoadFunction<d_g_date_strftime>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_strftime"));
public static ulong Strftime(string s, string format, GLib.Date date) {
IntPtr native_s = GLib.Marshaller.StringToPtrGStrdup (s);
IntPtr native_format = GLib.Marshaller.StringToPtrGStrdup (format);
UIntPtr raw_ret = g_date_strftime(native_s, new UIntPtr ((ulong) System.Text.Encoding.UTF8.GetByteCount (s)), native_format, date == null ? IntPtr.Zero : date.Handle);
ulong ret = (ulong) raw_ret;
GLib.Marshaller.Free (native_s);
GLib.Marshaller.Free (native_format);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_valid_day(byte day);
static d_g_date_valid_day g_date_valid_day = FuncLoader.LoadFunction<d_g_date_valid_day>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_valid_day"));
public static bool ValidDay(byte day) {
bool raw_ret = g_date_valid_day(day);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_valid_dmy(byte day, int month, ushort year);
static d_g_date_valid_dmy g_date_valid_dmy = FuncLoader.LoadFunction<d_g_date_valid_dmy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_valid_dmy"));
public static bool ValidDmy(byte day, int month, ushort year) {
bool raw_ret = g_date_valid_dmy(day, month, year);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_valid_julian(uint julian_date);
static d_g_date_valid_julian g_date_valid_julian = FuncLoader.LoadFunction<d_g_date_valid_julian>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_valid_julian"));
public static bool ValidJulian(uint julian_date) {
bool raw_ret = g_date_valid_julian(julian_date);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_valid_month(int month);
static d_g_date_valid_month g_date_valid_month = FuncLoader.LoadFunction<d_g_date_valid_month>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_valid_month"));
public static bool ValidMonth(int month) {
bool raw_ret = g_date_valid_month(month);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_valid_weekday(int weekday);
static d_g_date_valid_weekday g_date_valid_weekday = FuncLoader.LoadFunction<d_g_date_valid_weekday>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_valid_weekday"));
public static bool ValidWeekday(int weekday) {
bool raw_ret = g_date_valid_weekday(weekday);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_valid_year(ushort year);
static d_g_date_valid_year g_date_valid_year = FuncLoader.LoadFunction<d_g_date_valid_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_valid_year"));
public static bool ValidYear(ushort year) {
bool raw_ret = g_date_valid_year(year);
bool ret = raw_ret;
return ret;
}
public Date(IntPtr raw) : base(raw) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_new();
static d_g_date_new g_date_new = FuncLoader.LoadFunction<d_g_date_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_new"));
public Date ()
{
Raw = g_date_new();
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_new_dmy(byte day, int month, ushort year);
static d_g_date_new_dmy g_date_new_dmy = FuncLoader.LoadFunction<d_g_date_new_dmy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_new_dmy"));
public Date (byte day, int month, ushort year)
{
Raw = g_date_new_dmy(day, month, year);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_new_julian(uint julian_day);
static d_g_date_new_julian g_date_new_julian = FuncLoader.LoadFunction<d_g_date_new_julian>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_new_julian"));
public Date (uint julian_day)
{
Raw = g_date_new_julian(julian_day);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_free(IntPtr raw);
static d_g_date_free g_date_free = FuncLoader.LoadFunction<d_g_date_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_free"));
protected override void Free (IntPtr raw)
{
g_date_free (raw);
}
class FinalizerInfo {
IntPtr handle;
public FinalizerInfo (IntPtr handle)
{
this.handle = handle;
}
public bool Handler ()
{
g_date_free (handle);
return false;
}
}
~Date ()
{
if (!Owned)
return;
FinalizerInfo info = new FinalizerInfo (Handle);
GLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));
}
#endregion
}
}

View File

@@ -0,0 +1,513 @@
// 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;
#region Autogenerated code
public partial class DateTime : GLib.Opaque {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_get_type();
static d_g_date_time_get_type g_date_time_get_type = FuncLoader.LoadFunction<d_g_date_time_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_type"));
public static GLib.GType GType {
get {
IntPtr raw_ret = g_date_time_get_type();
GLib.GType ret = new GLib.GType(raw_ret);
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add(IntPtr raw, long timespan);
static d_g_date_time_add g_date_time_add = FuncLoader.LoadFunction<d_g_date_time_add>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add"));
public GLib.DateTime Add(long timespan) {
IntPtr raw_ret = g_date_time_add(Handle, timespan);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add_days(IntPtr raw, int days);
static d_g_date_time_add_days g_date_time_add_days = FuncLoader.LoadFunction<d_g_date_time_add_days>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add_days"));
public GLib.DateTime AddDays(int days) {
IntPtr raw_ret = g_date_time_add_days(Handle, days);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add_full(IntPtr raw, int years, int months, int days, int hours, int minutes, double seconds);
static d_g_date_time_add_full g_date_time_add_full = FuncLoader.LoadFunction<d_g_date_time_add_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add_full"));
public GLib.DateTime AddFull(int years, int months, int days, int hours, int minutes, double seconds) {
IntPtr raw_ret = g_date_time_add_full(Handle, years, months, days, hours, minutes, seconds);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add_hours(IntPtr raw, int hours);
static d_g_date_time_add_hours g_date_time_add_hours = FuncLoader.LoadFunction<d_g_date_time_add_hours>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add_hours"));
public GLib.DateTime AddHours(int hours) {
IntPtr raw_ret = g_date_time_add_hours(Handle, hours);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add_minutes(IntPtr raw, int minutes);
static d_g_date_time_add_minutes g_date_time_add_minutes = FuncLoader.LoadFunction<d_g_date_time_add_minutes>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add_minutes"));
public GLib.DateTime AddMinutes(int minutes) {
IntPtr raw_ret = g_date_time_add_minutes(Handle, minutes);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add_months(IntPtr raw, int months);
static d_g_date_time_add_months g_date_time_add_months = FuncLoader.LoadFunction<d_g_date_time_add_months>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add_months"));
public GLib.DateTime AddMonths(int months) {
IntPtr raw_ret = g_date_time_add_months(Handle, months);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add_seconds(IntPtr raw, double seconds);
static d_g_date_time_add_seconds g_date_time_add_seconds = FuncLoader.LoadFunction<d_g_date_time_add_seconds>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add_seconds"));
public GLib.DateTime AddSeconds(double seconds) {
IntPtr raw_ret = g_date_time_add_seconds(Handle, seconds);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add_weeks(IntPtr raw, int weeks);
static d_g_date_time_add_weeks g_date_time_add_weeks = FuncLoader.LoadFunction<d_g_date_time_add_weeks>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add_weeks"));
public GLib.DateTime AddWeeks(int weeks) {
IntPtr raw_ret = g_date_time_add_weeks(Handle, weeks);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_add_years(IntPtr raw, int years);
static d_g_date_time_add_years g_date_time_add_years = FuncLoader.LoadFunction<d_g_date_time_add_years>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_add_years"));
public GLib.DateTime AddYears(int years) {
IntPtr raw_ret = g_date_time_add_years(Handle, years);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate long d_g_date_time_difference(IntPtr raw, IntPtr begin);
static d_g_date_time_difference g_date_time_difference = FuncLoader.LoadFunction<d_g_date_time_difference>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_difference"));
public long Difference(GLib.DateTime begin) {
long raw_ret = g_date_time_difference(Handle, begin == null ? IntPtr.Zero : begin.Handle);
long ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_format(IntPtr raw, IntPtr format);
static d_g_date_time_format g_date_time_format = FuncLoader.LoadFunction<d_g_date_time_format>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_format"));
public string Format(string format) {
IntPtr native_format = GLib.Marshaller.StringToPtrGStrdup (format);
IntPtr raw_ret = g_date_time_format(Handle, native_format);
string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
GLib.Marshaller.Free (native_format);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_day_of_month(IntPtr raw);
static d_g_date_time_get_day_of_month g_date_time_get_day_of_month = FuncLoader.LoadFunction<d_g_date_time_get_day_of_month>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_day_of_month"));
public int DayOfMonth {
get {
int raw_ret = g_date_time_get_day_of_month(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_day_of_week(IntPtr raw);
static d_g_date_time_get_day_of_week g_date_time_get_day_of_week = FuncLoader.LoadFunction<d_g_date_time_get_day_of_week>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_day_of_week"));
public int DayOfWeek {
get {
int raw_ret = g_date_time_get_day_of_week(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_day_of_year(IntPtr raw);
static d_g_date_time_get_day_of_year g_date_time_get_day_of_year = FuncLoader.LoadFunction<d_g_date_time_get_day_of_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_day_of_year"));
public int DayOfYear {
get {
int raw_ret = g_date_time_get_day_of_year(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_hour(IntPtr raw);
static d_g_date_time_get_hour g_date_time_get_hour = FuncLoader.LoadFunction<d_g_date_time_get_hour>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_hour"));
public int Hour {
get {
int raw_ret = g_date_time_get_hour(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_microsecond(IntPtr raw);
static d_g_date_time_get_microsecond g_date_time_get_microsecond = FuncLoader.LoadFunction<d_g_date_time_get_microsecond>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_microsecond"));
public int Microsecond {
get {
int raw_ret = g_date_time_get_microsecond(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_minute(IntPtr raw);
static d_g_date_time_get_minute g_date_time_get_minute = FuncLoader.LoadFunction<d_g_date_time_get_minute>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_minute"));
public int Minute {
get {
int raw_ret = g_date_time_get_minute(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_month(IntPtr raw);
static d_g_date_time_get_month g_date_time_get_month = FuncLoader.LoadFunction<d_g_date_time_get_month>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_month"));
public int Month {
get {
int raw_ret = g_date_time_get_month(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_second(IntPtr raw);
static d_g_date_time_get_second g_date_time_get_second = FuncLoader.LoadFunction<d_g_date_time_get_second>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_second"));
public int Second {
get {
int raw_ret = g_date_time_get_second(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate double d_g_date_time_get_seconds(IntPtr raw);
static d_g_date_time_get_seconds g_date_time_get_seconds = FuncLoader.LoadFunction<d_g_date_time_get_seconds>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_seconds"));
public double Seconds {
get {
double raw_ret = g_date_time_get_seconds(Handle);
double ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_get_timezone_abbreviation(IntPtr raw);
static d_g_date_time_get_timezone_abbreviation g_date_time_get_timezone_abbreviation = FuncLoader.LoadFunction<d_g_date_time_get_timezone_abbreviation>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_timezone_abbreviation"));
public string TimezoneAbbreviation {
get {
IntPtr raw_ret = g_date_time_get_timezone_abbreviation(Handle);
string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate long d_g_date_time_get_utc_offset(IntPtr raw);
static d_g_date_time_get_utc_offset g_date_time_get_utc_offset = FuncLoader.LoadFunction<d_g_date_time_get_utc_offset>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_utc_offset"));
public long UtcOffset {
get {
long raw_ret = g_date_time_get_utc_offset(Handle);
long ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_week_numbering_year(IntPtr raw);
static d_g_date_time_get_week_numbering_year g_date_time_get_week_numbering_year = FuncLoader.LoadFunction<d_g_date_time_get_week_numbering_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_week_numbering_year"));
public int WeekNumberingYear {
get {
int raw_ret = g_date_time_get_week_numbering_year(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_week_of_year(IntPtr raw);
static d_g_date_time_get_week_of_year g_date_time_get_week_of_year = FuncLoader.LoadFunction<d_g_date_time_get_week_of_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_week_of_year"));
public int WeekOfYear {
get {
int raw_ret = g_date_time_get_week_of_year(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_get_year(IntPtr raw);
static d_g_date_time_get_year g_date_time_get_year = FuncLoader.LoadFunction<d_g_date_time_get_year>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_year"));
public int Year {
get {
int raw_ret = g_date_time_get_year(Handle);
int ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_time_get_ymd(IntPtr raw, out int year, out int month, out int day);
static d_g_date_time_get_ymd g_date_time_get_ymd = FuncLoader.LoadFunction<d_g_date_time_get_ymd>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_get_ymd"));
public void GetYmd(out int year, out int month, out int day) {
g_date_time_get_ymd(Handle, out year, out month, out day);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_time_is_daylight_savings(IntPtr raw);
static d_g_date_time_is_daylight_savings g_date_time_is_daylight_savings = FuncLoader.LoadFunction<d_g_date_time_is_daylight_savings>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_is_daylight_savings"));
public bool IsDaylightSavings {
get {
bool raw_ret = g_date_time_is_daylight_savings(Handle);
bool ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_to_local(IntPtr raw);
static d_g_date_time_to_local g_date_time_to_local = FuncLoader.LoadFunction<d_g_date_time_to_local>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_to_local"));
public GLib.DateTime ToLocal() {
IntPtr raw_ret = g_date_time_to_local(Handle);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_time_to_timeval(IntPtr raw, IntPtr tv);
static d_g_date_time_to_timeval g_date_time_to_timeval = FuncLoader.LoadFunction<d_g_date_time_to_timeval>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_to_timeval"));
public bool ToTimeval(GLib.TimeVal tv) {
IntPtr native_tv = GLib.Marshaller.StructureToPtrAlloc (tv);
bool raw_ret = g_date_time_to_timeval(Handle, native_tv);
bool ret = raw_ret;
tv = GLib.TimeVal.New (native_tv);
Marshal.FreeHGlobal (native_tv);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_to_timezone(IntPtr raw, IntPtr tz);
static d_g_date_time_to_timezone g_date_time_to_timezone = FuncLoader.LoadFunction<d_g_date_time_to_timezone>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_to_timezone"));
public GLib.DateTime ToTimezone(GLib.TimeZone tz) {
IntPtr raw_ret = g_date_time_to_timezone(Handle, tz == null ? IntPtr.Zero : tz.Handle);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate long d_g_date_time_to_unix(IntPtr raw);
static d_g_date_time_to_unix g_date_time_to_unix = FuncLoader.LoadFunction<d_g_date_time_to_unix>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_to_unix"));
public long ToUnix() {
long raw_ret = g_date_time_to_unix(Handle);
long ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_to_utc(IntPtr raw);
static d_g_date_time_to_utc g_date_time_to_utc = FuncLoader.LoadFunction<d_g_date_time_to_utc>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_to_utc"));
public GLib.DateTime ToUtc() {
IntPtr raw_ret = g_date_time_to_utc(Handle);
GLib.DateTime ret = raw_ret == IntPtr.Zero ? null : (GLib.DateTime) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.DateTime), true);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_date_time_compare(IntPtr dt1, IntPtr dt2);
static d_g_date_time_compare g_date_time_compare = FuncLoader.LoadFunction<d_g_date_time_compare>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_compare"));
public static int Compare(IntPtr dt1, IntPtr dt2) {
int raw_ret = g_date_time_compare(dt1, dt2);
int ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_date_time_equal(IntPtr dt1, IntPtr dt2);
static d_g_date_time_equal g_date_time_equal = FuncLoader.LoadFunction<d_g_date_time_equal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_equal"));
public static bool Equal(IntPtr dt1, IntPtr dt2) {
bool raw_ret = g_date_time_equal(dt1, dt2);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_date_time_hash(IntPtr datetime);
static d_g_date_time_hash g_date_time_hash = FuncLoader.LoadFunction<d_g_date_time_hash>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_hash"));
public static uint Hash(IntPtr datetime) {
uint raw_ret = g_date_time_hash(datetime);
uint ret = raw_ret;
return ret;
}
public DateTime(IntPtr raw) : base(raw) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new(IntPtr tz, int year, int month, int day, int hour, int minute, double seconds);
static d_g_date_time_new g_date_time_new = FuncLoader.LoadFunction<d_g_date_time_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new"));
public DateTime (GLib.TimeZone tz, int year, int month, int day, int hour, int minute, double seconds)
{
Raw = g_date_time_new(tz == null ? IntPtr.Zero : tz.Handle, year, month, day, hour, minute, seconds);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_from_timeval_local(IntPtr tv);
static d_g_date_time_new_from_timeval_local g_date_time_new_from_timeval_local = FuncLoader.LoadFunction<d_g_date_time_new_from_timeval_local>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_from_timeval_local"));
public DateTime (GLib.TimeVal tv)
{
IntPtr native_tv = GLib.Marshaller.StructureToPtrAlloc (tv);
Raw = g_date_time_new_from_timeval_local(native_tv);
tv = GLib.TimeVal.New (native_tv);
Marshal.FreeHGlobal (native_tv);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_from_timeval_utc(IntPtr tv);
static d_g_date_time_new_from_timeval_utc g_date_time_new_from_timeval_utc = FuncLoader.LoadFunction<d_g_date_time_new_from_timeval_utc>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_from_timeval_utc"));
public static DateTime NewFromTimevalUtc(GLib.TimeVal tv)
{
IntPtr native_tv = GLib.Marshaller.StructureToPtrAlloc (tv);
DateTime result = new DateTime (g_date_time_new_from_timeval_utc(native_tv));
tv = GLib.TimeVal.New (native_tv);
Marshal.FreeHGlobal (native_tv);
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_from_unix_local(long t);
static d_g_date_time_new_from_unix_local g_date_time_new_from_unix_local = FuncLoader.LoadFunction<d_g_date_time_new_from_unix_local>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_from_unix_local"));
public DateTime (long t)
{
Raw = g_date_time_new_from_unix_local(t);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_from_unix_utc(long t);
static d_g_date_time_new_from_unix_utc g_date_time_new_from_unix_utc = FuncLoader.LoadFunction<d_g_date_time_new_from_unix_utc>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_from_unix_utc"));
public static DateTime NewFromUnixUtc(long t)
{
DateTime result = new DateTime (g_date_time_new_from_unix_utc(t));
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_local(int year, int month, int day, int hour, int minute, double seconds);
static d_g_date_time_new_local g_date_time_new_local = FuncLoader.LoadFunction<d_g_date_time_new_local>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_local"));
public DateTime (int year, int month, int day, int hour, int minute, double seconds)
{
Raw = g_date_time_new_local(year, month, day, hour, minute, seconds);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_now(IntPtr tz);
static d_g_date_time_new_now g_date_time_new_now = FuncLoader.LoadFunction<d_g_date_time_new_now>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_now"));
public DateTime (GLib.TimeZone tz)
{
Raw = g_date_time_new_now(tz == null ? IntPtr.Zero : tz.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_now_local();
static d_g_date_time_new_now_local g_date_time_new_now_local = FuncLoader.LoadFunction<d_g_date_time_new_now_local>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_now_local"));
public DateTime ()
{
Raw = g_date_time_new_now_local();
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_now_utc();
static d_g_date_time_new_now_utc g_date_time_new_now_utc = FuncLoader.LoadFunction<d_g_date_time_new_now_utc>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_now_utc"));
public static DateTime NewNowUtc()
{
DateTime result = new DateTime (g_date_time_new_now_utc());
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_new_utc(int year, int month, int day, int hour, int minute, double seconds);
static d_g_date_time_new_utc g_date_time_new_utc = FuncLoader.LoadFunction<d_g_date_time_new_utc>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_new_utc"));
public static DateTime NewUtc(int year, int month, int day, int hour, int minute, double seconds)
{
DateTime result = new DateTime (g_date_time_new_utc(year, month, day, hour, minute, seconds));
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_date_time_ref(IntPtr raw);
static d_g_date_time_ref g_date_time_ref = FuncLoader.LoadFunction<d_g_date_time_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_ref"));
protected override void Ref (IntPtr raw)
{
if (!Owned) {
g_date_time_ref (raw);
Owned = true;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_date_time_unref(IntPtr raw);
static d_g_date_time_unref g_date_time_unref = FuncLoader.LoadFunction<d_g_date_time_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_date_time_unref"));
protected override void Unref (IntPtr raw)
{
if (Owned) {
g_date_time_unref (raw);
Owned = false;
}
}
class FinalizerInfo {
IntPtr handle;
public FinalizerInfo (IntPtr handle)
{
this.handle = handle;
}
public bool Handler ()
{
g_date_time_unref (handle);
return false;
}
}
~DateTime ()
{
if (!Owned)
return;
FinalizerInfo info = new FinalizerInfo (Handle);
GLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));
}
#endregion
}
}

View File

@@ -0,0 +1,53 @@
// DefaultSignalHandlerAttribute.cs
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2003 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
public sealed class DefaultSignalHandlerAttribute : Attribute
{
private string method;
private System.Type type;
public DefaultSignalHandlerAttribute () {}
public string ConnectionMethod
{
get {
return method;
}
set {
method = value;
}
}
public System.Type Type
{
get {
return type;
}
set {
type = value;
}
}
}
}

View File

@@ -0,0 +1,73 @@
// GLib.DestroyNotify.cs - internal DestroyNotify helper
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
public delegate void DestroyNotify (IntPtr data);
public class DestroyHelper {
private DestroyHelper () {}
static void ReleaseGCHandle (IntPtr data)
{
if (data == IntPtr.Zero)
return;
GCHandle gch = (GCHandle) data;
gch.Free ();
}
static DestroyNotify release_gchandle;
public static DestroyNotify NotifyHandler {
get {
if (release_gchandle == null)
release_gchandle = new DestroyNotify (ReleaseGCHandle);
return release_gchandle;
}
}
static void ReleaseSourceProxy (IntPtr data)
{
if (data == IntPtr.Zero)
return;
GCHandle gch = (GCHandle)data;
if (gch.Target is SourceProxy proxy) {
lock (proxy)
proxy.Dispose ();
}
gch.Free();
}
static DestroyNotify release_sourceproxy;
public static DestroyNotify SourceProxyNotifyHandler {
get {
if (release_sourceproxy == null)
release_sourceproxy = new DestroyNotify (ReleaseSourceProxy);
return release_sourceproxy;
}
}
}
}

View File

@@ -0,0 +1,74 @@
// GLib.Application.cs - static Application class
//
// Authors: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2007 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
public delegate void UnhandledExceptionHandler (UnhandledExceptionArgs args);
public class UnhandledExceptionArgs : System.UnhandledExceptionEventArgs {
bool exit_app = false;
public UnhandledExceptionArgs (Exception e, bool is_terminal) : base (e, is_terminal) {}
public bool ExitApplication {
get {
return exit_app;
}
set {
if (value)
exit_app = value;
}
}
}
public class ExceptionManager {
private ExceptionManager () {}
public static event UnhandledExceptionHandler UnhandledException;
public static void RaiseUnhandledException (Exception e, bool is_terminal)
{
if (UnhandledException == null) {
Console.Error.WriteLine ("Exception in Gtk# callback delegate");
Console.Error.WriteLine (" Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.");
Console.Error.WriteLine (e);
Console.Error.WriteLine (new System.Diagnostics.StackTrace (true));
Environment.Exit (1);
}
UnhandledExceptionArgs args = new UnhandledExceptionArgs (e, is_terminal);
try {
UnhandledException (args);
} catch (Exception ex) {
Console.Error.WriteLine (ex);
Environment.Exit (1);
}
if (is_terminal || args.ExitApplication)
Environment.Exit (1);
}
}
}

View File

@@ -0,0 +1,57 @@
// GLib.FileUtils.cs - GFileUtils class implementation
//
// Author: Martin Baulig <martin@gnome.org>
//
// Copyright (c) 2002 Ximian, Inc
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class FileUtils
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_file_get_contents(IntPtr filename, out IntPtr contents, out int length, out IntPtr error);
static d_g_file_get_contents g_file_get_contents = FuncLoader.LoadFunction<d_g_file_get_contents>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_file_get_contents"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_file_get_contents_utf8(IntPtr filename, out IntPtr contents, out int length, out IntPtr error);
static d_g_file_get_contents_utf8 g_file_get_contents_utf8 = FuncLoader.LoadFunction<d_g_file_get_contents_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_file_get_contents_utf8"));
public static string GetFileContents (string filename)
{
int length;
IntPtr contents, error;
IntPtr native_filename = Marshaller.StringToPtrGStrdup (filename);
if (Global.IsWindowsPlatform) {
if (!g_file_get_contents_utf8 (native_filename, out contents, out length, out error))
throw new GException (error);
} else {
if (!g_file_get_contents (native_filename, out contents, out length, out error))
throw new GException (error);
}
Marshaller.Free (native_filename);
return Marshaller.Utf8PtrToString (contents);
}
private FileUtils () {}
}
}

View File

@@ -0,0 +1,56 @@
// GException.cs : GError handling
//
// Authors: Rachel Hestilow <hestilow@ximian.com>
//
// Copyright (c) 2002 Rachel Hestilow
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class GException : Exception
{
string msg;
public GException (IntPtr errptr)
{
var err = (GError)Marshal.PtrToStructure(errptr, typeof(GError));
Domain = err.Domain;
Code = err.Code;
msg = Marshaller.Utf8PtrToString(err.Msg);
g_clear_error(ref errptr);
}
struct GError {
public int Domain;
public int Code;
public IntPtr Msg;
}
public int Code { get; private set; }
public int Domain { get; private set; }
public override string Message => msg;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_clear_error(ref IntPtr errptr);
static d_g_clear_error g_clear_error = FuncLoader.LoadFunction<d_g_clear_error>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_clear_error"));
}
}

View File

@@ -0,0 +1,61 @@
// GInterfaceAdapter.cs
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2007 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
public delegate void GInterfaceInitHandler (IntPtr iface_ptr, IntPtr data);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void GInterfaceFinalizeHandler (IntPtr iface_ptr, IntPtr data);
internal struct GInterfaceInfo {
internal GInterfaceInitHandler InitHandler;
internal GInterfaceFinalizeHandler FinalizeHandler;
internal IntPtr Data;
}
public abstract class GInterfaceAdapter {
GInterfaceInfo info;
protected GInterfaceAdapter ()
{
}
protected GInterfaceInitHandler InitHandler {
set {
info.InitHandler = value;
}
}
public abstract GType GInterfaceGType { get; }
public abstract IntPtr Handle { get; }
internal GInterfaceInfo Info {
get { return info; }
}
}
}

View File

@@ -0,0 +1,42 @@
// GInterfaceAttribute.cs
//
// Copyright (c) 2007 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
[AttributeUsage (AttributeTargets.Interface)]
public sealed class GInterfaceAttribute : Attribute {
Type adapter_type;
public GInterfaceAttribute (Type adapter_type)
{
this.adapter_type = adapter_type;
}
public Type AdapterType {
get {
return adapter_type;
}
set {
adapter_type = value;
}
}
}
}

View File

@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<api>
<namespace name="GLib" library="Library.GLib">
<enum name="ConnectFlags" cname="GConnectFlags" type="flags" />
<enum name="IOCondition" cname="GIOCondition" type="enum" />
<enum name="SeekType" cname="GSeekType" type="enum" />
<enum name="SpawnError" cname="GSpawnError" type="enum" />
<enum name="SpawnFlags" cname="GSpawnFlags" type="flags" />
<callback name="GSourceFunc" cname="GSourceFunc">
<return-type type="gboolean" />
<parameters>
<parameter type="gpointer" name="data" />
</parameters>
</callback>
<callback name="SpawnChildSetupFunc" cname="GSpawnChildSetupFunc">
<return-type type="void" />
<parameters>
<parameter type="gpointer" name="data" />
</parameters>
</callback>
<struct name="MarkupParser" cname="GMarkupParser" opaque="false" hidden="false">
<field cname="start_element" access="public" writeable="false" name="StartElement" type="GLibStartElementFunc"/>
<field cname="end_element" access="public" writeable="false" name="EndElement" type="GLibEndElementFunc"/>
<field cname="text" access="public" writeable="false" name="Text" type="GLibTextFunc"/>
<field cname="passthrough" access="public" writeable="false" name="Passthrough" type="GLibPassthroughFunc"/>
<field cname="error" access="public" writeable="false" name="Error" type="GError*">
<warning>missing glib:type-name</warning>
</field>
</struct>
</namespace>
<symbol type="manual" cname="GKeyFile" name="GLib.KeyFile" />
<symbol type="manual" cname="gvariant" name="GLib.Variant" />
</api>

View File

@@ -0,0 +1,92 @@
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.
namespace GLibSharp {
using System;
using System.Runtime.InteropServices;
#region Autogenerated code
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void SourceDummyMarshalNative();
internal class SourceDummyMarshalInvoker {
SourceDummyMarshalNative native_cb;
IntPtr __data;
GLib.DestroyNotify __notify;
~SourceDummyMarshalInvoker ()
{
if (__notify == null)
return;
__notify (__data);
}
internal SourceDummyMarshalInvoker (SourceDummyMarshalNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
internal SourceDummyMarshalInvoker (SourceDummyMarshalNative native_cb, IntPtr data) : this (native_cb, data, null) {}
internal SourceDummyMarshalInvoker (SourceDummyMarshalNative native_cb, IntPtr data, GLib.DestroyNotify notify)
{
this.native_cb = native_cb;
__data = data;
__notify = notify;
}
internal GLib.SourceDummyMarshal Handler {
get {
return new GLib.SourceDummyMarshal(InvokeNative);
}
}
void InvokeNative ()
{
native_cb ();
}
}
internal class SourceDummyMarshalWrapper {
public void NativeCallback ()
{
try {
managed ();
if (release_on_call)
gch.Free ();
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
}
}
bool release_on_call = false;
GCHandle gch;
public void PersistUntilCalled ()
{
release_on_call = true;
gch = GCHandle.Alloc (this);
}
internal SourceDummyMarshalNative NativeDelegate;
GLib.SourceDummyMarshal managed;
public SourceDummyMarshalWrapper (GLib.SourceDummyMarshal managed)
{
this.managed = managed;
if (managed != null)
NativeDelegate = new SourceDummyMarshalNative (NativeCallback);
}
public static GLib.SourceDummyMarshal GetManagedDelegate (SourceDummyMarshalNative native)
{
if (native == null)
return null;
SourceDummyMarshalWrapper wrapper = (SourceDummyMarshalWrapper) native.Target;
if (wrapper == null)
return null;
return wrapper.managed;
}
}
#endregion
}

View File

@@ -0,0 +1,95 @@
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.
namespace GLibSharp {
using System;
using System.Runtime.InteropServices;
#region Autogenerated code
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate bool SourceFuncNative(IntPtr user_data);
internal class SourceFuncInvoker {
SourceFuncNative native_cb;
IntPtr __data;
GLib.DestroyNotify __notify;
~SourceFuncInvoker ()
{
if (__notify == null)
return;
__notify (__data);
}
internal SourceFuncInvoker (SourceFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
internal SourceFuncInvoker (SourceFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {}
internal SourceFuncInvoker (SourceFuncNative native_cb, IntPtr data, GLib.DestroyNotify notify)
{
this.native_cb = native_cb;
__data = data;
__notify = notify;
}
internal GLib.SourceFunc Handler {
get {
return new GLib.SourceFunc(InvokeNative);
}
}
bool InvokeNative (IntPtr user_data)
{
bool __result = native_cb (__data);
return __result;
}
}
internal class SourceFuncWrapper {
public bool NativeCallback (IntPtr user_data)
{
try {
bool __ret = managed (user_data);
if (release_on_call)
gch.Free ();
return __ret;
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
return false;
}
}
bool release_on_call = false;
GCHandle gch;
public void PersistUntilCalled ()
{
release_on_call = true;
gch = GCHandle.Alloc (this);
}
internal SourceFuncNative NativeDelegate;
GLib.SourceFunc managed;
public SourceFuncWrapper (GLib.SourceFunc managed)
{
this.managed = managed;
if (managed != null)
NativeDelegate = new SourceFuncNative (NativeCallback);
}
public static GLib.SourceFunc GetManagedDelegate (SourceFuncNative native)
{
if (native == null)
return null;
SourceFuncWrapper wrapper = (SourceFuncWrapper) native.Target;
if (wrapper == null)
return null;
return wrapper.managed;
}
}
#endregion
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>GLibSharp is a C# wrapper for the GLib library.</Description>
<PackageTags>glib;glibsharp;glib-sharp;wrapper</PackageTags>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Shared\*.cs">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,71 @@
//
// GLibSynchronizationContext.cs
//
// Author:
// Rickard Edström <ickard@gmail.com>
//
// Copyright (c) 2010 Rickard Edström
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Threading;
namespace GLib
{
public class GLibSynchronizationContext : SynchronizationContext
{
public override void Post (SendOrPostCallback d, object state)
{
PostAction (() => d (state));
}
public override void Send (SendOrPostCallback d, object state)
{
var mre = new ManualResetEvent (false);
Exception error = null;
PostAction (() =>
{
try {
d (state);
} catch (Exception ex) {
error = ex;
} finally {
mre.Set ();
}
});
mre.WaitOne ();
if (error != null) {
throw error;
}
}
void PostAction (Action action)
{
Idle.Add (() =>
{
action ();
return false;
});
}
}
}

View File

@@ -0,0 +1,61 @@
// GLib.GString.cs : Marshaler for GStrings
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class GString : GLib.IWrapper {
IntPtr handle;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_string_free(IntPtr mem, bool free_segments);
static d_g_string_free g_string_free = FuncLoader.LoadFunction<d_g_string_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_string_free"));
~GString ()
{
g_string_free (handle, true);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_string_new(IntPtr text);
static d_g_string_new g_string_new = FuncLoader.LoadFunction<d_g_string_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_string_new"));
public GString (string text)
{
IntPtr native_text = Marshaller.StringToPtrGStrdup (text);
handle = g_string_new (native_text);
Marshaller.Free (native_text);
}
public IntPtr Handle {
get {
return handle;
}
}
public static string PtrToString (IntPtr ptr)
{
return Marshaller.Utf8PtrToString (ptr);
}
}
}

View File

@@ -0,0 +1,474 @@
// GLib.Type.cs - GLib GType class implementation
//
// Authors: Mike Kestner <mkestner@speakeasy.net>
// Andres G. Aragoneses <knocte@gmail.com>
//
// Copyright (c) 2003 Mike Kestner
// Copyright (c) 2003 Novell, Inc.
// Copyright (c) 2013 Andres G. Aragoneses
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
public delegate System.Type TypeResolutionHandler (GLib.GType gtype, string gtype_name);
[StructLayout(LayoutKind.Sequential)]
public struct GType {
IntPtr val;
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void ClassInitDelegate (IntPtr gobject_class_handle);
struct GTypeInfo {
public ushort class_size;
public IntPtr base_init;
public IntPtr base_finalize;
public ClassInitDelegate class_init;
public IntPtr class_finalize;
public IntPtr class_data;
public ushort instance_size;
public ushort n_preallocs;
public IntPtr instance_init;
public IntPtr value_table;
}
struct GTypeQuery {
public IntPtr type;
public IntPtr type_name;
public uint class_size;
public uint instance_size;
}
public GType (IntPtr val)
{
this.val = val;
}
public static GType FromName (string native_name)
{
return new GType (g_type_from_name (native_name));
}
public static readonly GType Invalid = new GType ((IntPtr) TypeFundamentals.TypeInvalid);
public static readonly GType None = new GType ((IntPtr) TypeFundamentals.TypeNone);
public static readonly GType Interface = new GType ((IntPtr) TypeFundamentals.TypeInterface);
public static readonly GType Char = new GType ((IntPtr) TypeFundamentals.TypeChar);
public static readonly GType UChar = new GType ((IntPtr) TypeFundamentals.TypeUChar);
public static readonly GType Boolean = new GType ((IntPtr) TypeFundamentals.TypeBoolean);
public static readonly GType Int = new GType ((IntPtr) TypeFundamentals.TypeInt);
public static readonly GType UInt = new GType ((IntPtr) TypeFundamentals.TypeUInt);
public static readonly GType Long = new GType ((IntPtr) TypeFundamentals.TypeLong);
public static readonly GType ULong = new GType ((IntPtr) TypeFundamentals.TypeULong);
public static readonly GType Int64 = new GType ((IntPtr) TypeFundamentals.TypeInt64);
public static readonly GType UInt64 = new GType ((IntPtr) TypeFundamentals.TypeUInt64);
public static readonly GType Enum = new GType ((IntPtr) TypeFundamentals.TypeEnum);
public static readonly GType Flags = new GType ((IntPtr) TypeFundamentals.TypeFlags);
public static readonly GType Float = new GType ((IntPtr) TypeFundamentals.TypeFloat);
public static readonly GType Double = new GType ((IntPtr) TypeFundamentals.TypeDouble);
public static readonly GType String = new GType ((IntPtr) TypeFundamentals.TypeString);
public static readonly GType Pointer = new GType ((IntPtr) TypeFundamentals.TypePointer);
public static readonly GType Boxed = new GType ((IntPtr) TypeFundamentals.TypeBoxed);
public static readonly GType Param = new GType ((IntPtr) TypeFundamentals.TypeParam);
public static readonly GType Object = new GType ((IntPtr) TypeFundamentals.TypeObject);
public static readonly GType Variant = new GType ((IntPtr) TypeFundamentals.TypeVariant);
static HashSet<GType> managedTypes = new HashSet<GType> ();
static IDictionary<IntPtr, Type> types = new Dictionary<IntPtr, Type> ();
static IDictionary<Type, GType> gtypes = new Dictionary<Type, GType> ();
public static void Register (GType native_type, System.Type type)
{
Register (native_type, type, false);
}
public static void Register (GType native_type, System.Type type, bool managed)
{
lock (types) {
if (native_type != GType.Pointer && native_type != GType.Boxed && native_type != ManagedValue.GType)
types[native_type.Val] = type;
if (type != null)
gtypes[type] = native_type;
if (managed)
managedTypes.Add(native_type);
}
}
public static bool IsManaged (GType gtype)
{
return managedTypes.Contains(gtype);
}
static GType ()
{
g_type_init ();
Register (GType.Char, typeof (sbyte));
Register (GType.UChar, typeof (byte));
Register (GType.Boolean, typeof (bool));
Register (GType.Int, typeof (int));
Register (GType.UInt, typeof (uint));
Register (GType.Int64, typeof (long));
Register (GType.UInt64, typeof (ulong));
Register (GType.Float, typeof (float));
Register (GType.Double, typeof (double));
Register (GType.String, typeof (string));
Register (GType.Pointer, typeof (IntPtr));
Register (GType.Object, typeof (GLib.Object));
Register (GType.Pointer, typeof (IntPtr));
Register (GType.Variant, typeof (GLib.Variant));
// One-way mapping
gtypes[typeof (char)] = GType.UInt;
}
public static explicit operator GType (System.Type type)
{
GType gtype;
lock (types) {
if (gtypes.ContainsKey (type))
return gtypes[type];
}
if (type.IsSubclassOf (typeof (GLib.Object))) {
gtype = GLib.Object.LookupGType (type);
Register (gtype, type);
return gtype;
}
PropertyInfo pi = type.GetProperty ("GType", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy);
if (pi != null)
gtype = (GType) pi.GetValue (null, null);
else if (type.IsDefined (typeof (GTypeAttribute), false)) {
GTypeAttribute gattr = (GTypeAttribute)Attribute.GetCustomAttribute (type, typeof (GTypeAttribute), false);
pi = gattr.WrapperType.GetProperty ("GType", BindingFlags.Public | BindingFlags.Static);
gtype = (GType) pi.GetValue (null, null);
} else if (type.IsSubclassOf (typeof (GLib.Opaque)))
gtype = GType.Pointer;
else
gtype = ManagedValue.GType;
Register (gtype, type);
return gtype;
}
static string GetQualifiedName (string cname)
{
if (string.IsNullOrEmpty (cname))
return null;
for (int i = 1; i < cname.Length; i++) {
if (System.Char.IsUpper (cname[i])) {
if (i == 1 && cname [0] == 'G')
return "GLib." + cname.Substring (1);
else
return cname.Substring (0, i) + "." + cname.Substring (i);
}
}
return null;
}
public static explicit operator Type (GType gtype)
{
return LookupType (gtype.Val);
}
public static void Init ()
{
// cctor already calls g_type_init.
}
public static event TypeResolutionHandler ResolveType;
public static Type LookupType (IntPtr typeid)
{
lock (types) {
if (types.ContainsKey (typeid))
return types[typeid];
}
string native_name = Marshaller.Utf8PtrToString (g_type_name (typeid));
if (ResolveType != null) {
GLib.GType gt = new GLib.GType (typeid);
Delegate[] invocation_list = ResolveType.GetInvocationList ();
foreach (Delegate d in invocation_list) {
TypeResolutionHandler handler = (TypeResolutionHandler) d;
System.Type tmp = handler (gt, native_name);
if (tmp != null) {
Register (gt, tmp);
return tmp;
}
}
}
string type_name = GetQualifiedName (native_name);
if (type_name == null)
return null;
Type result = null;
Assembly[] assemblies = (Assembly[]) AppDomain.CurrentDomain.GetAssemblies ().Clone ();
foreach (Assembly asm in assemblies) {
result = asm.GetType (type_name);
if (result != null)
break;
}
if (result == null
#if NET6_0_OR_GREATER
&& RuntimeFeature.IsDynamicCodeSupported
#endif
) {
// Because of lazy loading of references, it's possible the type's assembly
// needs to be loaded. We will look for it by name in the references of
// the currently loaded assemblies. Hopefully a recursive traversal is
// not needed. We avoid one for now because of problems experienced
// in a patch from bug #400595, and a desire to keep memory usage low
// by avoiding a complete loading of all dependent assemblies.
string ns = type_name.Substring (0, type_name.LastIndexOf ('.'));
string asm_name = ns.Replace (".", "") + "Sharp";
foreach (Assembly asm in assemblies) {
foreach (AssemblyName ref_name in asm.GetReferencedAssemblies ()) {
if (ref_name.Name != asm_name)
continue;
try {
string asm_dir = Path.GetDirectoryName (asm.Location); // will be null or empty for single file publish
Assembly ref_asm;
if (!string.IsNullOrEmpty (asm_dir) && File.Exists (Path.Combine (asm_dir, ref_name.Name + ".dll")))
ref_asm = Assembly.LoadFrom (Path.Combine (asm_dir, ref_name.Name + ".dll"));
else
ref_asm = Assembly.Load (ref_name);
result = ref_asm.GetType (type_name);
if (result != null)
break;
} catch (Exception) {
/* Failure to load a referenced assembly is not an error */
}
}
if (result != null)
break;
}
}
Register (new GType (typeid), result);
return result;
}
public IntPtr Val {
get { return val; }
}
public static bool operator == (GType a, GType b)
{
return a.Val == b.Val;
}
public static bool operator != (GType a, GType b)
{
return a.Val != b.Val;
}
public override bool Equals (object o)
{
if (!(o is GType))
return false;
return ((GType) o) == this;
}
public override int GetHashCode ()
{
return val.GetHashCode ();
}
public override string ToString ()
{
return Marshaller.Utf8PtrToString (g_type_name (val));
}
public IntPtr GetClassPtr ()
{
IntPtr klass = g_type_class_peek (val);
if (klass == IntPtr.Zero)
klass = g_type_class_ref (val);
return klass;
}
public IntPtr GetDefaultInterfacePtr ()
{
IntPtr klass = g_type_default_interface_peek (val);
if (klass == IntPtr.Zero)
klass = g_type_default_interface_ref (val);
return klass;
}
public GType GetBaseType ()
{
IntPtr parent = g_type_parent (this.Val);
return parent == IntPtr.Zero ? GType.None : new GType (parent);
}
public GType GetThresholdType ()
{
GType curr_type = this;
while (IsManaged (curr_type))
curr_type = curr_type.GetBaseType ();
return curr_type;
}
public uint GetClassSize ()
{
GTypeQuery query;
g_type_query (this.Val, out query);
return query.class_size;
}
internal void EnsureClass ()
{
if (g_type_class_peek (val) == IntPtr.Zero)
g_type_class_ref (val);
}
static int type_uid;
static string BuildEscapedName (System.Type t)
{
string qn = t.FullName;
// Just a random guess
StringBuilder sb = new StringBuilder (20 + qn.Length);
sb.Append ("__gtksharp_");
sb.Append (type_uid++);
sb.Append ("_");
foreach (char c in qn) {
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
sb.Append (c);
else if (c == '.')
sb.Append ('_');
else if ((uint) c <= byte.MaxValue) {
sb.Append ('+');
sb.Append (((byte) c).ToString ("x2"));
} else {
sb.Append ('-');
sb.Append (((uint) c).ToString ("x4"));
}
}
return sb.ToString ();
}
internal static GType RegisterGObjectType (Object.ClassInitializer gobject_class_initializer)
{
GType parent_gtype = LookupGObjectType (gobject_class_initializer.Type.BaseType);
TypeNameAttribute nattr = (TypeNameAttribute)Attribute.GetCustomAttribute (gobject_class_initializer.Type, typeof (TypeNameAttribute), false);
string name = nattr != null ? nattr.Name : BuildEscapedName (gobject_class_initializer.Type);
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
GTypeQuery query;
g_type_query (parent_gtype.Val, out query);
GTypeInfo info = new GTypeInfo ();
info.class_size = (ushort) query.class_size;
info.instance_size = (ushort) query.instance_size;
info.class_init = gobject_class_initializer.ClassInitManagedDelegate;
GType gtype = new GType (g_type_register_static (parent_gtype.Val, native_name, ref info, 0));
GLib.Marshaller.Free (native_name);
Register (gtype, gobject_class_initializer.Type, true);
return gtype;
}
internal static GType LookupGObjectType (System.Type t)
{
lock (types) {
if (gtypes.ContainsKey (t))
return gtypes [t];
}
PropertyInfo pi = t.GetProperty ("GType", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public);
if (pi != null)
return (GType) pi.GetValue (null, null);
return GLib.Object.RegisterGType (t);
}
internal static IntPtr ValFromInstancePtr (IntPtr handle)
{
if (handle == IntPtr.Zero)
return IntPtr.Zero;
// First field of instance is a GTypeClass*.
IntPtr klass = Marshal.ReadIntPtr (handle);
// First field of GTypeClass is a GType.
return Marshal.ReadIntPtr (klass);
}
internal static bool Is (IntPtr type, GType is_a_type)
{
return g_type_is_a (type, is_a_type.Val);
}
public bool IsInstance (IntPtr raw)
{
return GType.Is (ValFromInstancePtr (raw), this);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_class_peek(IntPtr gtype);
static d_g_type_class_peek g_type_class_peek = FuncLoader.LoadFunction<d_g_type_class_peek>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_class_peek"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_class_ref(IntPtr gtype);
static d_g_type_class_ref g_type_class_ref = FuncLoader.LoadFunction<d_g_type_class_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_class_ref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_default_interface_peek(IntPtr gtype);
static d_g_type_default_interface_peek g_type_default_interface_peek = FuncLoader.LoadFunction<d_g_type_default_interface_peek>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_default_interface_peek"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_default_interface_ref(IntPtr gtype);
static d_g_type_default_interface_ref g_type_default_interface_ref = FuncLoader.LoadFunction<d_g_type_default_interface_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_default_interface_ref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_from_name(string name);
static d_g_type_from_name g_type_from_name = FuncLoader.LoadFunction<d_g_type_from_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_from_name"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_type_init();
static d_g_type_init g_type_init = FuncLoader.LoadFunction<d_g_type_init>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_init"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_name(IntPtr raw);
static d_g_type_name g_type_name = FuncLoader.LoadFunction<d_g_type_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_name"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_parent(IntPtr type);
static d_g_type_parent g_type_parent = FuncLoader.LoadFunction<d_g_type_parent>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_parent"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_type_query(IntPtr type, out GTypeQuery query);
static d_g_type_query g_type_query = FuncLoader.LoadFunction<d_g_type_query>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_query"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_register_static(IntPtr parent, IntPtr name, ref GTypeInfo info, int flags);
static d_g_type_register_static g_type_register_static = FuncLoader.LoadFunction<d_g_type_register_static>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_register_static"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_type_is_a(IntPtr type, IntPtr is_a_type);
static d_g_type_is_a g_type_is_a = FuncLoader.LoadFunction<d_g_type_is_a>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_is_a"));
}
}

View File

@@ -0,0 +1,42 @@
// GTypeAttribute.cs
//
// Copyright (c) 2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
[AttributeUsage (AttributeTargets.Enum)]
public sealed class GTypeAttribute : Attribute {
Type wrapper_type;
public GTypeAttribute (Type wrapper_type)
{
this.wrapper_type = wrapper_type;
}
public Type WrapperType {
get {
return wrapper_type;
}
set {
wrapper_type = value;
}
}
}
}

View File

@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<api>
<namespace name="GLib" library="Library.GLib">
<enum name="ConnectFlags" cname="GConnectFlags" type="flags" />
<enum name="IOCondition" cname="GIOCondition" type="enum" />
<enum name="SeekType" cname="GSeekType" type="enum" />
<enum name="SpawnError" cname="GSpawnError" type="enum" />
<enum name="SpawnFlags" cname="GSpawnFlags" type="flags" />
<callback name="GSourceFunc" cname="GSourceFunc">
<return-type type="gboolean" />
<parameters>
<parameter type="gpointer" name="data" />
</parameters>
</callback>
<callback name="SpawnChildSetupFunc" cname="GSpawnChildSetupFunc">
<return-type type="void" />
<parameters>
<parameter type="gpointer" name="data" />
</parameters>
</callback>
<struct name="MarkupParser" cname="GMarkupParser" opaque="false" hidden="false">
<field cname="start_element" access="public" writeable="false" name="StartElement" type="GLibStartElementFunc"/>
<field cname="end_element" access="public" writeable="false" name="EndElement" type="GLibEndElementFunc"/>
<field cname="text" access="public" writeable="false" name="Text" type="GLibTextFunc"/>
<field cname="passthrough" access="public" writeable="false" name="Passthrough" type="GLibPassthroughFunc"/>
<field cname="error" access="public" writeable="false" name="Error" type="GError*">
<warning>missing glib:type-name</warning>
</field>
</struct>
</namespace>
<symbol type="manual" cname="GKeyFile" name="GLib.KeyFile" />
<symbol type="manual" cname="gvariant" name="GLib.Variant" />
</api>

View File

@@ -0,0 +1,93 @@
// GLib.Global.cs - Global glib properties and methods.
//
// Authors: Andres G. Aragoneses <aaragoneses@novell.com>
// Stephane Delcroix (stephane@delcroix.org)
//
// Copyright (c) 2008 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class Global
{
//this is a static class
private Global () {}
internal static bool IsWindowsPlatform {
get {
switch (Environment.OSVersion.Platform) {
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
return true;
default:
return false;
}
}
}
public static string ProgramName {
get {
return GLib.Marshaller.Utf8PtrToString (g_get_prgname());
}
set {
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (value);
g_set_prgname (native_name);
GLib.Marshaller.Free (native_name);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_set_prgname(IntPtr name);
static d_g_set_prgname g_set_prgname = FuncLoader.LoadFunction<d_g_set_prgname>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_set_prgname"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_get_prgname();
static d_g_get_prgname g_get_prgname = FuncLoader.LoadFunction<d_g_get_prgname>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_get_prgname"));
public static string ApplicationName {
get {
return GLib.Marshaller.Utf8PtrToString (g_get_application_name());
}
set {
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (value);
g_set_application_name (native_name);
GLib.Marshaller.Free (native_name);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_set_application_name(IntPtr name);
static d_g_set_application_name g_set_application_name = FuncLoader.LoadFunction<d_g_set_application_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_set_application_name"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_get_application_name();
static d_g_get_application_name g_get_application_name = FuncLoader.LoadFunction<d_g_get_application_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_get_application_name"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_format_size_for_display(long size);
static d_g_format_size_for_display g_format_size_for_display = FuncLoader.LoadFunction<d_g_format_size_for_display>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_format_size_for_display"));
static public string FormatSizeForDisplay (long size)
{
return Marshaller.PtrToStringGFree (g_format_size_for_display (size));
}
public static bool IsSupported => GLibrary.IsSupported(Library.GLib);
}
}

View File

@@ -0,0 +1,114 @@
// 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;
#region Autogenerated code
public partial class HookList : GLib.Opaque {
// Internal representation of the wrapped ABI structure.
static public unsafe AbiStruct abi_info = new AbiStruct(new List<AbiField> {
new GLib.AbiField("seq_id"
, 0
, (uint) sizeof (ulong) // seq_id
, null
, "hook_size"
, (long) Marshal.OffsetOf<GHookList_seq_idAlign>("seq_id")
, 0
),
new GLib.AbiField("hook_size"
, -1
, (uint) sizeof (uint) // hook_size
, "seq_id"
, "is_setup"
, 1
, 16
),
new GLib.AbiField("is_setup"
, -1
, (uint) Marshal.SizeOf<bool>() // is_setup
, "hook_size"
, "hooks"
, 1
, 1
),
new GLib.AbiField("hooks"
, -1
, (uint) sizeof (IntPtr) // hooks
, "is_setup"
, "dummy3"
, (long) Marshal.OffsetOf<GHookList_hooksAlign>("hooks")
, 0
),
new GLib.AbiField("dummy3"
, -1
, (uint) sizeof (IntPtr) // dummy3
, "hooks"
, "finalize_hook"
, (long) Marshal.OffsetOf<GHookList_dummy3Align>("dummy3")
, 0
),
new GLib.AbiField("finalize_hook"
, -1
, (uint) sizeof (IntPtr) // finalize_hook
, "dummy3"
, "dummy"
, (long) Marshal.OffsetOf<GHookList_finalize_hookAlign>("finalize_hook")
, 0
),
new GLib.AbiField("dummy"
, -1
, (uint) sizeof (IntPtr) * 2 // dummy
, "finalize_hook"
, null
, (long) Marshal.OffsetOf<GHookList_dummyAlign>("dummy")
, 0
)
}
);
[StructLayout(LayoutKind.Sequential)]
public struct GHookList_seq_idAlign
{
sbyte f1;
private UIntPtr seq_id;
}
[StructLayout(LayoutKind.Sequential)]
public struct GHookList_hooksAlign
{
sbyte f1;
private IntPtr hooks;
}
[StructLayout(LayoutKind.Sequential)]
public struct GHookList_dummy3Align
{
sbyte f1;
private IntPtr dummy3;
}
[StructLayout(LayoutKind.Sequential)]
public struct GHookList_finalize_hookAlign
{
sbyte f1;
private IntPtr finalize_hook;
}
[StructLayout(LayoutKind.Sequential)]
public struct GHookList_dummyAlign
{
sbyte f1;
[MarshalAs (UnmanagedType.ByValArray, SizeConst=2)]
private IntPtr[] dummy;
}
// End of the ABI representation.
#endregion
}
}

View File

@@ -0,0 +1,473 @@
// glib/IOChannel.cs : IOChannel API wrapper
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2007 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLibSharp {
using System;
using System.Runtime.InteropServices;
using GLib;
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate bool IOFuncNative(IntPtr source, int condition, IntPtr data);
internal class IOFuncWrapper {
IOFunc managed;
public IOFuncNative NativeDelegate;
public IOFuncWrapper (IOFunc managed)
{
this.managed = managed;
NativeDelegate = new IOFuncNative (NativeCallback);
}
bool NativeCallback (IntPtr source, int condition, IntPtr data)
{
try {
return managed (IOChannel.FromHandle (source), (IOCondition) condition);
} catch (Exception e) {
ExceptionManager.RaiseUnhandledException (e, false);
return false;
}
}
}
}
namespace GLib {
using System;
using System.Runtime.InteropServices;
using GLibSharp;
public class IOChannel : IDisposable, IWrapper {
IntPtr handle;
private IOChannel(IntPtr handle)
{
this.handle = handle;
}
public IOChannel (int fd) : this (g_io_channel_unix_new (fd)) {}
public IOChannel (string filename, string mode)
{
IntPtr native_filename = Marshaller.StringToPtrGStrdup (filename);
IntPtr native_mode = Marshaller.StringToPtrGStrdup (mode);
IntPtr error;
if (Global.IsWindowsPlatform)
handle = g_io_channel_new_file_utf8(native_filename, native_mode, out error);
else
handle = g_io_channel_new_file(native_filename, native_mode, out error);
Marshaller.Free (native_filename);
Marshaller.Free (native_mode);
if (error != IntPtr.Zero) throw new GException (error);
}
public IOCondition BufferCondition
{
get {
return (IOCondition) g_io_channel_get_buffer_condition (Handle);
}
}
public bool Buffered
{
get {
return g_io_channel_get_buffered (Handle);
}
set {
g_io_channel_set_buffered (Handle, value);
}
}
public ulong BufferSize
{
get {
return (ulong) g_io_channel_get_buffer_size (Handle);
}
set {
g_io_channel_set_buffer_size (Handle, new UIntPtr (value));
}
}
public bool CloseOnUnref
{
get {
return g_io_channel_get_close_on_unref (Handle);
}
set {
g_io_channel_set_close_on_unref (Handle, value);
}
}
public string Encoding
{
get {
return Marshaller.Utf8PtrToString (g_io_channel_get_encoding (Handle));
}
set {
IntPtr native_encoding = Marshaller.StringToPtrGStrdup (value);
IntPtr error;
g_io_channel_set_encoding (Handle, native_encoding, out error);
Marshaller.Free (native_encoding);
if (error != IntPtr.Zero) throw new GException (error);
}
}
public IOFlags Flags
{
get {
return (IOFlags) g_io_channel_get_flags(Handle);
}
set {
IntPtr error;
g_io_channel_set_flags(Handle, (int) value, out error);
if (error != IntPtr.Zero) throw new GException (error);
}
}
public char[] LineTerminator {
get {
int length;
IntPtr raw = g_io_channel_get_line_term (Handle, out length);
if (length == -1)
return Marshaller.Utf8PtrToString (raw).ToCharArray ();
byte[] buffer = new byte [length];
return System.Text.Encoding.UTF8.GetChars (buffer);
}
set {
byte[] buffer = System.Text.Encoding.UTF8.GetBytes (value);
g_io_channel_set_line_term (Handle, buffer, buffer.Length);
}
}
public IntPtr Handle {
get {
return handle;
}
}
public int UnixFd {
get {
return g_io_channel_unix_get_fd (Handle);
}
}
protected void Init ()
{
g_io_channel_init (Handle);
}
public void Dispose ()
{
g_io_channel_unref (Handle);
}
public uint AddWatch (int priority, IOCondition condition, IOFunc func)
{
if (func == null)
return 0;
IOFuncWrapper func_wrapper = new IOFuncWrapper (func);
IntPtr user_data = (IntPtr) GCHandle.Alloc (func_wrapper);
DestroyNotify notify = DestroyHelper.NotifyHandler;
return g_io_add_watch_full (Handle, priority, (int) condition, func_wrapper.NativeDelegate, user_data, notify);
}
public IOStatus Flush ()
{
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_flush (Handle, out error);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public IOStatus ReadChars (byte[] buf, out ulong bytes_read)
{
UIntPtr native_bytes_read;
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_read_chars (Handle, buf, new UIntPtr ((ulong) buf.Length), out native_bytes_read, out error);
bytes_read = (ulong) native_bytes_read;
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public IOStatus ReadLine (out string str_return)
{
ulong dump;
return ReadLine (out str_return, out dump);
}
public IOStatus ReadLine (out string str_return, out ulong terminator_pos)
{
IntPtr native_string;
UIntPtr native_terminator_pos;
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_read_line (Handle, out native_string, IntPtr.Zero, out native_terminator_pos, out error);
terminator_pos = (ulong) native_terminator_pos;
str_return = null;
if (ret == IOStatus.Normal)
str_return = Marshaller.PtrToStringGFree (native_string);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public IOStatus ReadToEnd (out string str_return)
{
IntPtr native_str;
UIntPtr native_length;
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_read_to_end (Handle, out native_str, out native_length, out error);
str_return = null;
if (ret == IOStatus.Normal) {
byte[] buffer = new byte [(ulong) native_length];
Marshal.Copy (native_str, buffer, 0, (int)(ulong) native_length);
str_return = System.Text.Encoding.UTF8.GetString (buffer);
}
Marshaller.Free (native_str);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public IOStatus ReadUnichar (out uint thechar)
{
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_read_unichar (Handle, out thechar, out error);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public IOStatus SeekPosition (long offset, SeekType type)
{
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_seek_position (Handle, offset, (int) type, out error);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public IOStatus Shutdown (bool flush)
{
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_shutdown (Handle, flush, out error);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public IOStatus WriteChars (string str, out string remainder)
{
ulong written;
System.Text.Encoding enc = System.Text.Encoding.UTF8;
byte[] buffer = enc.GetBytes (str);
IOStatus ret = WriteChars (buffer, out written);
remainder = null;
if ((int) written == buffer.Length)
return ret;
int count = buffer.Length - (int) written;
byte[] rem = new byte [count];
Array.Copy (buffer, (int) written, rem, 0, count);
remainder = enc.GetString (rem);
return ret;
}
public IOStatus WriteChars (byte[] buf, out ulong bytes_written)
{
UIntPtr native_bytes_written;
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_write_chars (Handle, buf, new IntPtr (buf.Length), out native_bytes_written, out error);
bytes_written = (ulong) native_bytes_written;
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public IOStatus WriteUnichar (uint thechar)
{
IntPtr error;
IOStatus ret = (IOStatus) g_io_channel_write_unichar (Handle, thechar, out error);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public static IOChannel FromHandle (IntPtr handle)
{
if (handle == IntPtr.Zero)
return null;
g_io_channel_ref (handle);
return new IOChannel (handle);
}
public static IOChannelError ErrorFromErrno (int en)
{
return (IOChannelError) g_io_channel_error_from_errno (en);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_io_channel_unix_new(int fd);
static d_g_io_channel_unix_new g_io_channel_unix_new = FuncLoader.LoadFunction<d_g_io_channel_unix_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_unix_new"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_io_channel_new_file(IntPtr filename, IntPtr mode, out IntPtr error);
static d_g_io_channel_new_file g_io_channel_new_file = FuncLoader.LoadFunction<d_g_io_channel_new_file>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_new_file"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_io_channel_new_file_utf8(IntPtr filename, IntPtr mode, out IntPtr error);
static d_g_io_channel_new_file_utf8 g_io_channel_new_file_utf8 = FuncLoader.LoadFunction<d_g_io_channel_new_file_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_new_file_utf8"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_error_quark();
static d_g_io_channel_error_quark g_io_channel_error_quark = FuncLoader.LoadFunction<d_g_io_channel_error_quark>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_error_quark"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_error_from_errno(int en);
static d_g_io_channel_error_from_errno g_io_channel_error_from_errno = FuncLoader.LoadFunction<d_g_io_channel_error_from_errno>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_error_from_errno"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_flush(IntPtr raw, out IntPtr error);
static d_g_io_channel_flush g_io_channel_flush = FuncLoader.LoadFunction<d_g_io_channel_flush>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_flush"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_io_channel_init(IntPtr raw);
static d_g_io_channel_init g_io_channel_init = FuncLoader.LoadFunction<d_g_io_channel_init>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_init"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_read_chars(IntPtr raw, byte[] buf, UIntPtr count, out UIntPtr bytes_read, out IntPtr error);
static d_g_io_channel_read_chars g_io_channel_read_chars = FuncLoader.LoadFunction<d_g_io_channel_read_chars>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_read_chars"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_read_line(IntPtr raw, out IntPtr str_return, IntPtr length, out UIntPtr terminator_pos, out IntPtr error);
static d_g_io_channel_read_line g_io_channel_read_line = FuncLoader.LoadFunction<d_g_io_channel_read_line>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_read_line"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_read_to_end(IntPtr raw, out IntPtr str_return, out UIntPtr length, out IntPtr error);
static d_g_io_channel_read_to_end g_io_channel_read_to_end = FuncLoader.LoadFunction<d_g_io_channel_read_to_end>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_read_to_end"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_read_unichar(IntPtr raw, out uint thechar, out IntPtr error);
static d_g_io_channel_read_unichar g_io_channel_read_unichar = FuncLoader.LoadFunction<d_g_io_channel_read_unichar>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_read_unichar"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_seek_position(IntPtr raw, long offset, int type, out IntPtr error);
static d_g_io_channel_seek_position g_io_channel_seek_position = FuncLoader.LoadFunction<d_g_io_channel_seek_position>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_seek_position"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_shutdown(IntPtr raw, bool flush, out IntPtr err);
static d_g_io_channel_shutdown g_io_channel_shutdown = FuncLoader.LoadFunction<d_g_io_channel_shutdown>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_shutdown"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_write_chars(IntPtr raw, byte[] buf, IntPtr count, out UIntPtr bytes_written, out IntPtr error);
static d_g_io_channel_write_chars g_io_channel_write_chars = FuncLoader.LoadFunction<d_g_io_channel_write_chars>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_write_chars"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_write_unichar(IntPtr raw, uint thechar, out IntPtr error);
static d_g_io_channel_write_unichar g_io_channel_write_unichar = FuncLoader.LoadFunction<d_g_io_channel_write_unichar>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_write_unichar"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_get_buffer_condition(IntPtr raw);
static d_g_io_channel_get_buffer_condition g_io_channel_get_buffer_condition = FuncLoader.LoadFunction<d_g_io_channel_get_buffer_condition>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_get_buffer_condition"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_io_channel_get_buffered(IntPtr raw);
static d_g_io_channel_get_buffered g_io_channel_get_buffered = FuncLoader.LoadFunction<d_g_io_channel_get_buffered>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_get_buffered"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_io_channel_set_buffered(IntPtr raw, bool buffered);
static d_g_io_channel_set_buffered g_io_channel_set_buffered = FuncLoader.LoadFunction<d_g_io_channel_set_buffered>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_set_buffered"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate UIntPtr d_g_io_channel_get_buffer_size(IntPtr raw);
static d_g_io_channel_get_buffer_size g_io_channel_get_buffer_size = FuncLoader.LoadFunction<d_g_io_channel_get_buffer_size>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_get_buffer_size"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_io_channel_set_buffer_size(IntPtr raw, UIntPtr size);
static d_g_io_channel_set_buffer_size g_io_channel_set_buffer_size = FuncLoader.LoadFunction<d_g_io_channel_set_buffer_size>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_set_buffer_size"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_io_channel_get_close_on_unref(IntPtr raw);
static d_g_io_channel_get_close_on_unref g_io_channel_get_close_on_unref = FuncLoader.LoadFunction<d_g_io_channel_get_close_on_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_get_close_on_unref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_io_channel_set_close_on_unref(IntPtr raw, bool do_close);
static d_g_io_channel_set_close_on_unref g_io_channel_set_close_on_unref = FuncLoader.LoadFunction<d_g_io_channel_set_close_on_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_set_close_on_unref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_io_channel_get_encoding(IntPtr raw);
static d_g_io_channel_get_encoding g_io_channel_get_encoding = FuncLoader.LoadFunction<d_g_io_channel_get_encoding>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_get_encoding"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_set_encoding(IntPtr raw, IntPtr encoding, out IntPtr error);
static d_g_io_channel_set_encoding g_io_channel_set_encoding = FuncLoader.LoadFunction<d_g_io_channel_set_encoding>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_set_encoding"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_get_flags(IntPtr raw);
static d_g_io_channel_get_flags g_io_channel_get_flags = FuncLoader.LoadFunction<d_g_io_channel_get_flags>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_get_flags"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_set_flags(IntPtr raw, int flags, out IntPtr error);
static d_g_io_channel_set_flags g_io_channel_set_flags = FuncLoader.LoadFunction<d_g_io_channel_set_flags>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_set_flags"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_io_channel_get_line_term(IntPtr raw, out int length);
static d_g_io_channel_get_line_term g_io_channel_get_line_term = FuncLoader.LoadFunction<d_g_io_channel_get_line_term>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_get_line_term"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_io_channel_set_line_term(IntPtr raw, byte[] term, int length);
static d_g_io_channel_set_line_term g_io_channel_set_line_term = FuncLoader.LoadFunction<d_g_io_channel_set_line_term>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_set_line_term"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_io_channel_unix_get_fd(IntPtr raw);
static d_g_io_channel_unix_get_fd g_io_channel_unix_get_fd = FuncLoader.LoadFunction<d_g_io_channel_unix_get_fd>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_unix_get_fd"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_io_channel_ref(IntPtr raw);
static d_g_io_channel_ref g_io_channel_ref = FuncLoader.LoadFunction<d_g_io_channel_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_ref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_io_channel_unref(IntPtr raw);
static d_g_io_channel_unref g_io_channel_unref = FuncLoader.LoadFunction<d_g_io_channel_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_channel_unref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_io_add_watch_full(IntPtr raw, int priority, int condition, IOFuncNative func, IntPtr user_data, DestroyNotify notify);
static d_g_io_add_watch_full g_io_add_watch_full = FuncLoader.LoadFunction<d_g_io_add_watch_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_add_watch_full"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_io_create_watch(IntPtr raw, int condition);
static d_g_io_create_watch g_io_create_watch = FuncLoader.LoadFunction<d_g_io_create_watch>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_io_create_watch"));
}
public delegate bool IOFunc (IOChannel source, IOCondition condition);
public enum IOChannelError {
FileTooBig,
Inval,
IO,
IsDir,
NoSpace,
Nxio,
Overflow,
Pipe,
Failed,
}
[Flags]
public enum IOCondition {
In = 1 << 0,
Out = 1 << 2,
Pri = 1 << 1,
Err = 1 << 3,
Hup = 1 << 4,
Nval = 1 << 5,
}
[Flags]
public enum IOFlags {
Append = 1 << 0,
Nonblock = 1 << 1,
IsReadable = 1 << 2,
IsWriteable = 1 << 3,
IsSeekable = 1 << 4,
Mask = 1 << 5- 1,
GetMask = Mask,
SetMask = Append | Nonblock,
}
public enum IOStatus {
Error,
Normal,
Eof,
Again,
}
public enum SeekType {
Cur,
Set,
End,
}
}

View File

@@ -0,0 +1,30 @@
// IWrapper.cs - Common code for GInterfaces and GObjects
//
// Author: Rachel Hestilow <hesitlow@ximian.com>
//
// Copyright (c) 2002 Rachel Hestilow
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib
{
using System;
public interface IWrapper
{
IntPtr Handle { get; }
}
}

View File

@@ -0,0 +1,96 @@
// GLib.Idle.cs - Idle class implementation
//
// Author(s):
// Mike Kestner <mkestner@speakeasy.net>
// Rachel Hestilow <hestilow@ximian.com>
// Stephane Delcroix <stephane@delcroix.org>
//
// Copyright (c) 2002 Mike Kestner
// Copyright (c) Rachel Hestilow
// Copyright (c) 2009 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public delegate bool IdleHandler ();
public class Idle {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate bool IdleHandlerInternal ();
internal class IdleProxy : SourceProxy {
public IdleProxy (IdleHandler real)
{
real_handler = real;
proxy_handler = new IdleHandlerInternal (Handler);
}
public bool Handler ()
{
try {
IdleHandler idle_handler = (IdleHandler) real_handler;
bool cont = idle_handler ();
return cont;
} catch (Exception e) {
ExceptionManager.RaiseUnhandledException (e, false);
}
return false;
}
}
private Idle ()
{
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_idle_add_full(int priority, IdleHandlerInternal d, IntPtr data, DestroyNotify notify);
static d_g_idle_add_full g_idle_add_full = FuncLoader.LoadFunction<d_g_idle_add_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_idle_add_full"));
public static uint Add (int priority, IdleHandler hndlr)
{
IdleProxy p = new IdleProxy (hndlr);
lock (p)
{
var gch = GCHandle.Alloc(p);
var userData = GCHandle.ToIntPtr(gch);
p.ID = g_idle_add_full (priority, (IdleHandlerInternal) p.proxy_handler, userData, DestroyHelper.SourceProxyNotifyHandler);
}
return p.ID;
}
public static uint Add (Priority priority, IdleHandler hndlr)
{
return Add ((int)priority, hndlr);
}
public static uint Add (IdleHandler hndlr)
{
return Add ((int)Priority.DefaultIdle, hndlr);
}
public static void Remove (uint id)
{
Source.Remove (id);
}
}
}

View File

@@ -0,0 +1,73 @@
// InitiallyUnowned.cs - GInitiallyUnowned class wrapper implementation
//
// Authors: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2004-2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class InitiallyUnowned : Object {
protected InitiallyUnowned (IntPtr raw) : base (raw) {}
delegate IntPtr d_g_initially_unowned_get_type ();
static d_g_initially_unowned_get_type g_initially_unowned_get_type = FuncLoader.LoadFunction<d_g_initially_unowned_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_initially_unowned_get_type"));
public new static GLib.GType GType {
get {
IntPtr raw_ret = g_initially_unowned_get_type();
GLib.GType ret = new GLib.GType(raw_ret);
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_object_ref_sink(IntPtr raw);
static d_g_object_ref_sink g_object_ref_sink = FuncLoader.LoadFunction<d_g_object_ref_sink>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_ref_sink"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_object_is_floating(IntPtr raw);
static d_g_object_is_floating g_object_is_floating = FuncLoader.LoadFunction<d_g_object_is_floating>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_is_floating"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_object_force_floating(IntPtr raw);
static d_g_object_force_floating g_object_force_floating = FuncLoader.LoadFunction<d_g_object_force_floating>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_force_floating"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_object_unref(IntPtr raw);
static d_g_object_unref g_object_unref = FuncLoader.LoadFunction<d_g_object_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_unref"));
public bool IsFloating {
get {
return g_object_is_floating (Handle);
}
set {
if (value == true) {
if (!IsFloating)
g_object_force_floating (Handle);
} else {
g_object_ref_sink (Handle);
g_object_unref (Handle);
}
}
}
}
}

View File

@@ -0,0 +1,729 @@
// Copyright (c) 2008-2011 Novell, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Runtime.InteropServices;
namespace GLib {
public enum KeyFileError {
UnknownEncoding,
Parse,
NotFound,
KeyNotFound,
GroupNotFound,
InvalidValue,
}
[Flags]
public enum KeyFileFlags {
None,
KeepComments = 1 << 0,
KeepTranslations = 1 << 1,
}
public class KeyFile : IDisposable {
IntPtr handle;
bool owned;
class FinalizerInfo {
IntPtr handle;
public FinalizerInfo (IntPtr handle)
{
this.handle = handle;
}
public bool Handler ()
{
g_key_file_free (handle);
return false;
}
}
~KeyFile ()
{
if (!owned)
return;
if (handle == IntPtr.Zero)
return;
FinalizerInfo info = new FinalizerInfo (Handle);
Timeout.Add (50, new TimeoutHandler (info.Handler));
}
public void Dispose ()
{
if (owned && handle != IntPtr.Zero)
g_key_file_free (handle);
handle = IntPtr.Zero;
GC.SuppressFinalize (this);
}
public KeyFile (IntPtr handle) : this (handle, false) {}
public KeyFile (IntPtr handle, bool owned)
{
this.handle = handle;
this.owned = owned;
}
public KeyFile () : this (g_key_file_new (), true) {}
public KeyFile (string file) : this (file, KeyFileFlags.KeepComments) {}
public KeyFile (string file, KeyFileFlags flags) : this ()
{
LoadFromFile (file, flags);
}
public string[] Groups {
get { return Marshaller.NullTermPtrToStringArray (g_key_file_get_groups (Handle, IntPtr.Zero), true); }
}
public IntPtr Handle {
get { return handle; }
}
public string StartGroup {
get { return Marshaller.PtrToStringGFree (g_key_file_get_start_group (Handle)); }
}
public bool GetBoolean (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
bool ret = g_key_file_get_boolean (Handle, native_group_name, native_key, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public bool[] GetBooleanList (string group_name, string key)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
UIntPtr native_length;
IntPtr error;
IntPtr raw_ret = g_key_file_get_boolean_list (Handle, native_group_name, native_key, out native_length, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
int length = (int) (ulong) native_length;
int[] ints = new int [length];
Marshal.Copy (raw_ret, ints, 0, length);
Marshaller.Free (raw_ret);
bool[] ret = new bool [length];
for (int i = 0; i < length; i++)
ret [i] = ints [i] != 0;
return ret;
}
public string GetComment (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
string ret = Marshaller.PtrToStringGFree (g_key_file_get_comment (Handle, native_group_name, native_key, out error));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public double GetDouble (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
double ret = g_key_file_get_double (Handle, native_group_name, native_key, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public double[] GetDoubleList (string group_name, string key)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
UIntPtr native_length;
IntPtr error;
IntPtr raw_ret = g_key_file_get_double_list(Handle, native_group_name, native_key, out native_length, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
int length = (int) (ulong)native_length;
double[] ret = new double [length];
Marshal.Copy (raw_ret, ret, 0, length);
Marshaller.Free (raw_ret);
return ret;
}
public int GetInteger (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
int ret = g_key_file_get_integer (Handle, native_group_name, native_key, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public long GetInt64 (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
long ret = g_key_file_get_int64 (Handle, native_group_name, native_key, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public ulong GetUInt64 (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
ulong ret = g_key_file_get_uint64 (Handle, native_group_name, native_key, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public int[] GetIntegerList (string group_name, string key)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
UIntPtr native_length;
IntPtr error;
IntPtr raw_ret = g_key_file_get_integer_list(Handle, native_group_name, native_key, out native_length, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
int length = (int) (ulong) native_length;
int[] ret = new int [length];
Marshal.Copy (raw_ret, ret, 0, length);
Marshaller.Free (raw_ret);
return ret;
}
public string[] GetKeys (string group_name)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
string[] ret = Marshaller.NullTermPtrToStringArray (g_key_file_get_keys (Handle, native_group_name, IntPtr.Zero, out error), true);
Marshaller.Free (native_group_name);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public string GetLocaleString (string group_name, string key, string locale)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
IntPtr native_locale = Marshaller.StringToPtrGStrdup (locale);
string ret = Marshaller.PtrToStringGFree (g_key_file_get_locale_string (Handle, native_group_name, native_key, native_locale, out error));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
Marshaller.Free (native_locale);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public string[] GetLocaleStringList (string group_name, string key, string locale)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
IntPtr native_locale = Marshaller.StringToPtrGStrdup (locale);
string[] ret = Marshaller.NullTermPtrToStringArray (g_key_file_get_locale_string_list (Handle, native_group_name, native_key, native_locale, IntPtr.Zero, out error), true);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
Marshaller.Free (native_locale);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public string GetString (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
string ret = Marshaller.PtrToStringGFree (g_key_file_get_string (Handle, native_group_name, native_key, out error));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public string[] GetStringList (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
string[] ret = Marshaller.NullTermPtrToStringArray (g_key_file_get_string_list (Handle, native_group_name, native_key, IntPtr.Zero, out error), true);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public string GetValue (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
string ret = Marshaller.PtrToStringGFree (g_key_file_get_value (Handle, native_group_name, native_key, out error));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public bool HasGroup (string group_name)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
bool ret = g_key_file_has_group(Handle, native_group_name);
Marshaller.Free (native_group_name);
return ret;
}
public bool HasKey (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
bool ret = g_key_file_has_key (Handle, native_group_name, native_key, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public bool LoadFromData (byte[] data, KeyFileFlags flags)
{
if (data == null)
throw new ArgumentNullException ("data");
IntPtr error;
bool ret = g_key_file_load_from_data (Handle, data, new UIntPtr ((ulong) data.Length), (int) flags, out error);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public bool LoadFromDataDirs (string file, out string full_path, KeyFileFlags flags)
{
IntPtr error;
IntPtr native_full_path;
IntPtr native_file = Marshaller.StringToPtrGStrdup (file);
bool ret = g_key_file_load_from_data_dirs(Handle, native_file, out native_full_path, (int) flags, out error);
Marshaller.Free (native_file);
if (error != IntPtr.Zero) throw new GException (error);
full_path = Marshaller.PtrToStringGFree (native_full_path);
return ret;
}
public bool LoadFromDirs (string file, string[] search_dirs, out string full_path, KeyFileFlags flags)
{
IntPtr error;
IntPtr native_full_path;
IntPtr native_file = Marshaller.StringToPtrGStrdup (file);
IntPtr native_search_dirs = Marshaller.StringArrayToStrvPtr (search_dirs);
bool ret = g_key_file_load_from_dirs (Handle, native_file, native_search_dirs, out native_full_path, (int) flags, out error);
Marshaller.Free (native_file);
Marshaller.StrFreeV (native_search_dirs);
if (error != IntPtr.Zero) throw new GException (error);
full_path = Marshaller.PtrToStringGFree (native_full_path);
return ret;
}
public bool LoadFromFile (string file, KeyFileFlags flags)
{
IntPtr error;
IntPtr native_file = Marshaller.StringToFilenamePtr (file);
bool ret = g_key_file_load_from_file (Handle, native_file, (int) flags, out error);
Marshaller.Free (native_file);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public bool RemoveComment (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
bool ret = g_key_file_remove_comment (Handle, native_group_name, native_key, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public bool RemoveGroup (string group_name)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
bool ret = g_key_file_remove_group (Handle, native_group_name, out error);
Marshaller.Free (native_group_name);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public bool RemoveKey (string group_name, string key)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
bool ret = g_key_file_remove_key (Handle, native_group_name, native_key, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public void Save (string filename)
{
byte [] content = ToData ();
System.IO.FileStream stream = System.IO.File.Create (filename);
stream.Write (content, 0, content.Length);
stream.Close ();
}
public void SetBoolean (string group_name, string key, bool value)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
g_key_file_set_boolean (Handle, native_group_name, native_key, value);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
}
public void SetBooleanList (string group_name, string key, bool[] list)
{
if (list == null)
throw new ArgumentNullException ("list");
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
g_key_file_set_boolean_list (Handle, native_group_name, native_key, list, new UIntPtr ((ulong) (list.Length)));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
}
public bool SetComment (string group_name, string key, string comment)
{
IntPtr error;
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
IntPtr native_comment = Marshaller.StringToPtrGStrdup (comment);
bool ret = g_key_file_set_comment (Handle, native_group_name, native_key, native_comment, out error);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
Marshaller.Free (native_comment);
if (error != IntPtr.Zero) throw new GException (error);
return ret;
}
public void SetDouble (string group_name, string key, double value)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
g_key_file_set_double (Handle, native_group_name, native_key, value);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
}
public void SetDoubleList (string group_name, string key, double[] list)
{
if (list == null)
throw new ArgumentNullException ("list");
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
g_key_file_set_double_list (Handle, native_group_name, native_key, list, new UIntPtr ((ulong) (list.Length)));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
}
public void SetInteger (string group_name, string key, int value)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
g_key_file_set_integer (Handle, native_group_name, native_key, value);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
}
public void SetInt64 (string group_name, string key, long value)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
g_key_file_set_int64 (Handle, native_group_name, native_key, value);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
}
public void SetUInt64 (string group_name, string key, ulong value)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
g_key_file_set_uint64 (Handle, native_group_name, native_key, value);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
}
public void SetIntegerList (string group_name, string key, int[] list)
{
if (list == null)
throw new ArgumentNullException ("list");
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
g_key_file_set_integer_list (Handle, native_group_name, native_key, list, new UIntPtr ((ulong) list.Length));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
}
public void SetListSeparator (char value)
{
g_key_file_set_list_separator (Handle, (byte) value);
}
public void SetLocaleString (string group_name, string key, string locale, string value)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
IntPtr native_locale = Marshaller.StringToPtrGStrdup (locale);
IntPtr native_value = Marshaller.StringToPtrGStrdup (value);
g_key_file_set_locale_string (Handle, native_group_name, native_key, native_locale, native_value);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
Marshaller.Free (native_locale);
Marshaller.Free (native_value);
}
public void SetLocaleStringList (string group_name, string key, string locale, string[] list)
{
if (key == null)
throw new ArgumentNullException ("key");
if (locale == null)
throw new ArgumentNullException ("locale");
if (list == null)
throw new ArgumentNullException ("list");
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
IntPtr native_locale = Marshaller.StringToPtrGStrdup (locale);
IntPtr native_list = Marshaller.StringArrayToStrvPtr (list);
g_key_file_set_locale_string_list (Handle, native_group_name, native_key, native_locale, native_list, new UIntPtr ((ulong)list.Length));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
Marshaller.Free (native_locale);
Marshaller.StrFreeV (native_list);
}
public void SetString (string group_name, string key, string value)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
IntPtr native_value = Marshaller.StringToPtrGStrdup (value);
g_key_file_set_string (Handle, native_group_name, native_key, native_value);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
Marshaller.Free (native_value);
}
public void SetStringList (string group_name, string key, string[] list)
{
if (list == null)
throw new ArgumentNullException ("list");
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
IntPtr native_list = Marshaller.StringArrayToStrvPtr (list);
g_key_file_set_string_list (Handle, native_group_name, native_key, native_list, new UIntPtr ((ulong)list.Length));
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
Marshaller.StrFreeV (native_list);
}
public void SetValue (string group_name, string key, string value)
{
IntPtr native_group_name = Marshaller.StringToPtrGStrdup (group_name);
IntPtr native_key = Marshaller.StringToPtrGStrdup (key);
IntPtr native_value = Marshaller.StringToPtrGStrdup (value);
g_key_file_set_value (Handle, native_group_name, native_key, native_value);
Marshaller.Free (native_group_name);
Marshaller.Free (native_key);
Marshaller.Free (native_value);
}
public byte[] ToData ()
{
UIntPtr native_length;
IntPtr raw_ret = g_key_file_to_data (Handle, out native_length, IntPtr.Zero);
int length = (int)native_length;
byte[] ret = new byte [length];
Marshal.Copy (raw_ret, ret, 0, length);
Marshaller.Free (raw_ret);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_free(IntPtr raw);
static d_g_key_file_free g_key_file_free = FuncLoader.LoadFunction<d_g_key_file_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_free"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_get_boolean(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_get_boolean g_key_file_get_boolean = FuncLoader.LoadFunction<d_g_key_file_get_boolean>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_boolean"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_boolean_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
static d_g_key_file_get_boolean_list g_key_file_get_boolean_list = FuncLoader.LoadFunction<d_g_key_file_get_boolean_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_boolean_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_comment(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_get_comment g_key_file_get_comment = FuncLoader.LoadFunction<d_g_key_file_get_comment>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_comment"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate double d_g_key_file_get_double(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_get_double g_key_file_get_double = FuncLoader.LoadFunction<d_g_key_file_get_double>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_double"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_double_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
static d_g_key_file_get_double_list g_key_file_get_double_list = FuncLoader.LoadFunction<d_g_key_file_get_double_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_double_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_groups(IntPtr raw, IntPtr dummy);
static d_g_key_file_get_groups g_key_file_get_groups = FuncLoader.LoadFunction<d_g_key_file_get_groups>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_groups"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_key_file_get_integer(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_get_integer g_key_file_get_integer = FuncLoader.LoadFunction<d_g_key_file_get_integer>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_integer"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_integer_list(IntPtr raw, IntPtr group_name, IntPtr key, out UIntPtr length, out IntPtr error);
static d_g_key_file_get_integer_list g_key_file_get_integer_list = FuncLoader.LoadFunction<d_g_key_file_get_integer_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_integer_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_keys(IntPtr raw, IntPtr group_name, IntPtr dummy, out IntPtr error);
static d_g_key_file_get_keys g_key_file_get_keys = FuncLoader.LoadFunction<d_g_key_file_get_keys>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_keys"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_locale_string(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr locale, out IntPtr error);
static d_g_key_file_get_locale_string g_key_file_get_locale_string = FuncLoader.LoadFunction<d_g_key_file_get_locale_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_locale_string"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_locale_string_list(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr locale, IntPtr dummy, out IntPtr error);
static d_g_key_file_get_locale_string_list g_key_file_get_locale_string_list = FuncLoader.LoadFunction<d_g_key_file_get_locale_string_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_locale_string_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_start_group(IntPtr raw);
static d_g_key_file_get_start_group g_key_file_get_start_group = FuncLoader.LoadFunction<d_g_key_file_get_start_group>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_start_group"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_string(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_get_string g_key_file_get_string = FuncLoader.LoadFunction<d_g_key_file_get_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_string"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_string_list(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr dummy, out IntPtr error);
static d_g_key_file_get_string_list g_key_file_get_string_list = FuncLoader.LoadFunction<d_g_key_file_get_string_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_string_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_get_value(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_get_value g_key_file_get_value = FuncLoader.LoadFunction<d_g_key_file_get_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_value"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_has_group(IntPtr raw, IntPtr group_name);
static d_g_key_file_has_group g_key_file_has_group = FuncLoader.LoadFunction<d_g_key_file_has_group>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_has_group"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_has_key(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_has_key g_key_file_has_key = FuncLoader.LoadFunction<d_g_key_file_has_key>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_has_key"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_load_from_data(IntPtr raw, byte[] data, UIntPtr length, int flags, out IntPtr error);
static d_g_key_file_load_from_data g_key_file_load_from_data = FuncLoader.LoadFunction<d_g_key_file_load_from_data>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_load_from_data"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_load_from_data_dirs(IntPtr raw, IntPtr file, out IntPtr full_path, int flags, out IntPtr error);
static d_g_key_file_load_from_data_dirs g_key_file_load_from_data_dirs = FuncLoader.LoadFunction<d_g_key_file_load_from_data_dirs>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_load_from_data_dirs"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_load_from_dirs(IntPtr raw, IntPtr file, IntPtr search_dirs, out IntPtr full_path, int flags, out IntPtr error);
static d_g_key_file_load_from_dirs g_key_file_load_from_dirs = FuncLoader.LoadFunction<d_g_key_file_load_from_dirs>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_load_from_dirs"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_load_from_file(IntPtr raw, IntPtr file, int flags, out IntPtr error);
static d_g_key_file_load_from_file g_key_file_load_from_file = FuncLoader.LoadFunction<d_g_key_file_load_from_file>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_load_from_file"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_new();
static d_g_key_file_new g_key_file_new = FuncLoader.LoadFunction<d_g_key_file_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_new"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_remove_comment(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_remove_comment g_key_file_remove_comment = FuncLoader.LoadFunction<d_g_key_file_remove_comment>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_remove_comment"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_remove_group(IntPtr raw, IntPtr group_name, out IntPtr error);
static d_g_key_file_remove_group g_key_file_remove_group = FuncLoader.LoadFunction<d_g_key_file_remove_group>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_remove_group"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_remove_key(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_remove_key g_key_file_remove_key = FuncLoader.LoadFunction<d_g_key_file_remove_key>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_remove_key"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_boolean(IntPtr raw, IntPtr group_name, IntPtr key, bool value);
static d_g_key_file_set_boolean g_key_file_set_boolean = FuncLoader.LoadFunction<d_g_key_file_set_boolean>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_boolean"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_boolean_list(IntPtr raw, IntPtr group_name, IntPtr key, bool[] list, UIntPtr n_list);
static d_g_key_file_set_boolean_list g_key_file_set_boolean_list = FuncLoader.LoadFunction<d_g_key_file_set_boolean_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_boolean_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_key_file_set_comment(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr comment, out IntPtr error);
static d_g_key_file_set_comment g_key_file_set_comment = FuncLoader.LoadFunction<d_g_key_file_set_comment>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_comment"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_double(IntPtr raw, IntPtr group_name, IntPtr key, double value);
static d_g_key_file_set_double g_key_file_set_double = FuncLoader.LoadFunction<d_g_key_file_set_double>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_double"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_double_list(IntPtr raw, IntPtr group_name, IntPtr key, double[] list, UIntPtr n_list);
static d_g_key_file_set_double_list g_key_file_set_double_list = FuncLoader.LoadFunction<d_g_key_file_set_double_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_double_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_integer(IntPtr raw, IntPtr group_name, IntPtr key, int value);
static d_g_key_file_set_integer g_key_file_set_integer = FuncLoader.LoadFunction<d_g_key_file_set_integer>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_integer"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_integer_list(IntPtr raw, IntPtr group_name, IntPtr key, int[] list, UIntPtr n_list);
static d_g_key_file_set_integer_list g_key_file_set_integer_list = FuncLoader.LoadFunction<d_g_key_file_set_integer_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_integer_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_list_separator(IntPtr raw, byte separator);
static d_g_key_file_set_list_separator g_key_file_set_list_separator = FuncLoader.LoadFunction<d_g_key_file_set_list_separator>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_list_separator"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_locale_string(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr locale, IntPtr value);
static d_g_key_file_set_locale_string g_key_file_set_locale_string = FuncLoader.LoadFunction<d_g_key_file_set_locale_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_locale_string"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_locale_string_list(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr locale, IntPtr list, UIntPtr length);
static d_g_key_file_set_locale_string_list g_key_file_set_locale_string_list = FuncLoader.LoadFunction<d_g_key_file_set_locale_string_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_locale_string_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_string(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr value);
static d_g_key_file_set_string g_key_file_set_string = FuncLoader.LoadFunction<d_g_key_file_set_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_string"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_string_list(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr list, UIntPtr n_list);
static d_g_key_file_set_string_list g_key_file_set_string_list = FuncLoader.LoadFunction<d_g_key_file_set_string_list>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_string_list"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_value(IntPtr raw, IntPtr group_name, IntPtr key, IntPtr value);
static d_g_key_file_set_value g_key_file_set_value = FuncLoader.LoadFunction<d_g_key_file_set_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_value"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_key_file_to_data(IntPtr raw, out UIntPtr length, IntPtr dummy);
static d_g_key_file_to_data g_key_file_to_data = FuncLoader.LoadFunction<d_g_key_file_to_data>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_to_data"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate long d_g_key_file_get_int64(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_get_int64 g_key_file_get_int64 = FuncLoader.LoadFunction<d_g_key_file_get_int64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_int64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate ulong d_g_key_file_get_uint64(IntPtr raw, IntPtr group_name, IntPtr key, out IntPtr error);
static d_g_key_file_get_uint64 g_key_file_get_uint64 = FuncLoader.LoadFunction<d_g_key_file_get_uint64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_get_uint64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_int64(IntPtr raw, IntPtr group_name, IntPtr key, long value);
static d_g_key_file_set_int64 g_key_file_set_int64 = FuncLoader.LoadFunction<d_g_key_file_set_int64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_int64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_key_file_set_uint64(IntPtr raw, IntPtr group_name, IntPtr key, ulong value);
static d_g_key_file_set_uint64 g_key_file_set_uint64 = FuncLoader.LoadFunction<d_g_key_file_set_uint64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_key_file_set_uint64"));
}
}

View File

@@ -0,0 +1,100 @@
// List.cs - GList class wrapper implementation
//
// Authors: Mike Kestner <mkestner@speakeasy.net>
//
// Copyright (c) 2002 Mike Kestner
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class List : ListBase {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_list_copy(IntPtr l);
static d_g_list_copy g_list_copy = FuncLoader.LoadFunction<d_g_list_copy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_list_copy"));
public override object Clone ()
{
return new List (g_list_copy (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_list_length(IntPtr l);
static d_g_list_length g_list_length = FuncLoader.LoadFunction<d_g_list_length>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_list_length"));
internal override int Length (IntPtr list)
{
return g_list_length (list);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_list_free(IntPtr l);
static d_g_list_free g_list_free = FuncLoader.LoadFunction<d_g_list_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_list_free"));
internal override void Free (IntPtr list)
{
if (list != IntPtr.Zero)
g_list_free (list);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_list_append(IntPtr l, IntPtr raw);
static d_g_list_append g_list_append = FuncLoader.LoadFunction<d_g_list_append>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_list_append"));
internal override IntPtr Append (IntPtr list, IntPtr raw)
{
return g_list_append (list, raw);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_list_prepend(IntPtr l, IntPtr raw);
static d_g_list_prepend g_list_prepend = FuncLoader.LoadFunction<d_g_list_prepend>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_list_prepend"));
internal override IntPtr Prepend (IntPtr list, IntPtr raw)
{
return g_list_prepend (list, raw);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_list_nth_data(IntPtr l, uint n);
static d_g_list_nth_data g_list_nth_data = FuncLoader.LoadFunction<d_g_list_nth_data>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_list_nth_data"));
internal override IntPtr NthData (uint n)
{
return g_list_nth_data (Handle, n);
}
public List (IntPtr raw) : this (raw, null) {}
public List (System.Type element_type) : this (IntPtr.Zero, element_type) {}
public List (IntPtr raw, System.Type element_type) : this (raw, element_type, false, false) {}
public List (IntPtr raw, System.Type element_type, bool owned, bool elements_owned) : base (raw, element_type, owned, elements_owned) {}
public List (object[] elements, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned)
{
foreach (object o in elements)
Append (o);
}
public List (Array elements, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned)
{
foreach (object o in elements)
Append (o);
}
}
}

View File

@@ -0,0 +1,290 @@
// ListBase.cs - List base class implementation
//
// Authors: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2002 Mike Kestner
// Copyright (c) 2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections;
using System.Runtime.InteropServices;
public abstract class ListBase : IDisposable, ICollection, GLib.IWrapper, ICloneable {
private IntPtr list_ptr = IntPtr.Zero;
private int length = -1;
private bool managed = false;
internal bool elements_owned = false;
protected System.Type element_type = null;
abstract internal IntPtr NthData (uint index);
abstract internal int Length (IntPtr list);
abstract internal void Free (IntPtr list);
abstract internal IntPtr Append (IntPtr current, IntPtr raw);
abstract internal IntPtr Prepend (IntPtr current, IntPtr raw);
internal ListBase (IntPtr list, System.Type element_type, bool owned, bool elements_owned)
{
list_ptr = list;
this.element_type = element_type;
managed = owned;
this.elements_owned = elements_owned;
}
~ListBase ()
{
Dispose (false);
}
[Obsolete ("Replaced by owned parameter on ctor.")]
public bool Managed {
set { managed = value; }
}
public IntPtr Handle {
get {
return list_ptr;
}
}
public void Append (IntPtr raw)
{
list_ptr = Append (list_ptr, raw);
}
public void Append (string item)
{
this.Append (Marshaller.StringToPtrGStrdup (item));
}
public void Append (object item)
{
this.Append (AllocNativeElement (item));
}
public void Prepend (IntPtr raw)
{
list_ptr = Prepend (list_ptr, raw);
}
// ICollection
public int Count {
get {
if (length == -1)
length = Length (list_ptr);
return length;
}
}
public object this [int index] {
get {
IntPtr data = NthData ((uint) index);
object ret = null;
ret = DataMarshal (data);
return ret;
}
}
// Synchronization could be tricky here. Hmm.
public bool IsSynchronized {
get { return false; }
}
public object SyncRoot {
get { return null; }
}
public void CopyTo (Array array, int index)
{
object[] orig = new object[Count];
int i = 0;
foreach (object o in this)
orig [i++] = o;
orig.CopyTo (array, index);
}
public class FilenameString {
private FilenameString () {}
}
IntPtr AllocNativeElement (object element)
{
if (element_type == null) {
if (element is IWrapper)
return (element as IWrapper).Handle;
else
return (IntPtr) GCHandle.Alloc (element);
} else {
if (element_type == typeof (string))
return Marshaller.StringToPtrGStrdup (element as string);
else if (element_type == typeof (FilenameString))
return Marshaller.StringToFilenamePtr (element as string);
else if (element_type == typeof (IntPtr))
return (IntPtr) GCHandle.Alloc (element);
else if (typeof (IWrapper).IsAssignableFrom (element_type))
return (element as IWrapper).Handle;
else if (element_type == typeof (int))
return new IntPtr ((int) element);
else if (element_type.IsValueType)
return Marshaller.StructureToPtrAlloc (element);
}
return IntPtr.Zero;
}
internal object DataMarshal (IntPtr data)
{
object ret = null;
if (element_type != null) {
if (element_type == typeof (string))
ret = Marshaller.Utf8PtrToString (data);
else if (element_type == typeof (FilenameString))
ret = Marshaller.FilenamePtrToString (data);
else if (element_type == typeof (IntPtr))
ret = data;
else if (element_type.IsSubclassOf (typeof (GLib.Object)))
ret = GLib.Object.GetObject (data, false);
else if (element_type.IsSubclassOf (typeof (GLib.Opaque)))
ret = GLib.Opaque.GetOpaque (data, element_type, elements_owned);
else if (element_type == typeof (int))
ret = (int) data;
else if (element_type.IsValueType)
ret = Marshal.PtrToStructure (data, element_type);
else if (element_type.IsInterface) {
Type adapter_type = element_type.Assembly.GetType (InterfaceToAdapterTypeName (element_type));
System.Reflection.MethodInfo method = adapter_type.GetMethod ("GetObject", new Type[] {typeof(IntPtr), typeof(bool)});
ret = method.Invoke (null, new object[] {data, false});
} else
ret = Activator.CreateInstance (element_type, new object[] {data});
} else if (Object.IsObject (data))
ret = GLib.Object.GetObject (data, false);
return ret;
}
static string InterfaceToAdapterTypeName (Type type)
{
string fullname = type.Namespace;
if (!String.IsNullOrEmpty (fullname)) {
fullname += ".";
}
fullname += type.Name.Substring (1); // IActivatable -> Activatable
return fullname + "Adapter";
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_object_unref(IntPtr item);
static d_g_object_unref g_object_unref = FuncLoader.LoadFunction<d_g_object_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_unref"));
public void Empty ()
{
if (elements_owned) {
for (uint i = 0; i < Count; i++) {
if (typeof (GLib.Opaque).IsAssignableFrom (element_type)) {
GLib.Opaque.GetOpaque (NthData (i), element_type, true).Dispose ();
} else if (typeof (GLib.IWrapper).IsAssignableFrom (element_type)) {
g_object_unref (NthData (i));
} else {
Marshaller.Free (NthData (i));
}
}
}
if (managed)
FreeList ();
}
IntPtr GetData (IntPtr current)
{
// data field is at offset 0 for GList and GSList
return Marshal.ReadIntPtr (current);
}
IntPtr Next (IntPtr current)
{
// next field follows gpointer data field for GList and GSList
return Marshal.ReadIntPtr (current, IntPtr.Size);
}
private class ListEnumerator : IEnumerator
{
private IntPtr current = IntPtr.Zero;
private ListBase list;
public ListEnumerator (ListBase list)
{
this.list = list;
}
public object Current {
get {
IntPtr data = list.GetData (current);
object ret = null;
ret = list.DataMarshal (data);
return ret;
}
}
public bool MoveNext ()
{
if (current == IntPtr.Zero)
current = list.list_ptr;
else
current = list.Next (current);
return (current != IntPtr.Zero);
}
public void Reset ()
{
current = IntPtr.Zero;
}
}
// IEnumerable
public IEnumerator GetEnumerator ()
{
return new ListEnumerator (this);
}
// IDisposable
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
Empty ();
}
void FreeList ()
{
if (list_ptr != IntPtr.Zero)
Free (list_ptr);
list_ptr = IntPtr.Zero;
length = -1;
}
// ICloneable
abstract public object Clone ();
}
}

View File

@@ -0,0 +1,293 @@
// Log.cs - Wrapper for message logging functions
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
//
// Copyright (c) 2002 Gonzalo Paniagua
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
namespace GLib {
using System;
using System.Runtime.InteropServices;
public delegate void LogFunc (string log_domain, LogLevelFlags log_level, string message);
public delegate void PrintFunc (string message);
[Flags]
public enum LogLevelFlags : int
{
/* log flags */
FlagRecursion = 1 << 0,
FlagFatal = 1 << 1,
/* GLib log levels */
Error = 1 << 2, /* always fatal */
Critical = 1 << 3,
Warning = 1 << 4,
Message = 1 << 5,
Info = 1 << 6,
Debug = 1 << 7,
/* Convenience values */
AllButFatal = 253,
AllButRecursion = 254,
All = 255,
FlagMask = 3,
LevelMask = unchecked ((int) 0xFFFFFFFC)
}
public class Log {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void LogFuncNative (IntPtr log_domain, LogLevelFlags flags, IntPtr message, IntPtr user_data);
static LogFuncNative native_handler;
static void NativeCallback (IntPtr log_domain_native, LogLevelFlags flags, IntPtr message_native, IntPtr user_data)
{
if (user_data == IntPtr.Zero)
return;
string log_domain = Marshaller.Utf8PtrToString (log_domain_native);
string message = Marshaller.Utf8PtrToString (message_native);
GCHandle gch = (GCHandle) user_data;
LogFunc func = gch.Target as LogFunc;
if (func != null)
func (log_domain, flags, message);
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void PrintFuncNative (IntPtr message);
class PrintHelper {
PrintFuncNative native;
PrintFunc managed;
public PrintHelper (PrintFuncNative native)
{
this.native = native;
}
public PrintHelper (PrintFunc managed)
{
this.managed = managed;
GCHandle.Alloc (this);
}
void Callback (IntPtr nmessage)
{
string message = Marshaller.Utf8PtrToString (nmessage);
managed (message);
}
void Invoke (string message)
{
IntPtr nmessage = Marshaller.StringToPtrGStrdup (message);
native (nmessage);
Marshaller.Free (nmessage);
}
public PrintFuncNative Handler {
get { return new PrintFuncNative (Callback); }
}
public PrintFunc Invoker {
get { return new PrintFunc (Invoke); }
}
}
static System.Collections.Generic.Dictionary<uint, GCHandle> handlers;
static void EnsureHash ()
{
if (handlers == null)
handlers = new System.Collections.Generic.Dictionary<uint, GCHandle> ();
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_logv(IntPtr log_domain, LogLevelFlags flags, IntPtr message);
static d_g_logv g_logv = FuncLoader.LoadFunction<d_g_logv>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_logv"));
public void WriteLog (string logDomain, LogLevelFlags flags, string format, params object [] args)
{
IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
IntPtr nmessage = Marshaller.StringToPtrGStrdup (String.Format (format, args));
g_logv (ndom, flags, nmessage);
Marshaller.Free (ndom);
Marshaller.Free (nmessage);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_log_set_handler(IntPtr log_domain, LogLevelFlags flags, LogFuncNative log_func, IntPtr user_data);
static d_g_log_set_handler g_log_set_handler = FuncLoader.LoadFunction<d_g_log_set_handler>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_log_set_handler"));
public static uint SetLogHandler (string logDomain, LogLevelFlags flags, LogFunc logFunc)
{
if (native_handler == null)
native_handler = new LogFuncNative (NativeCallback);
IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
GCHandle gch = GCHandle.Alloc (logFunc);
uint result = g_log_set_handler (ndom, flags, native_handler, (IntPtr) gch);
Marshaller.Free (ndom);
EnsureHash ();
handlers [result] = gch;
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_log_remove_handler(IntPtr log_domain, uint handler_id);
static d_g_log_remove_handler g_log_remove_handler = FuncLoader.LoadFunction<d_g_log_remove_handler>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_log_remove_handler"));
public static void RemoveLogHandler (string logDomain, uint handlerID)
{
if (handlers != null && handlers.ContainsKey (handlerID)) {
handlers [handlerID].Free ();
handlers.Remove (handlerID);
}
IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
g_log_remove_handler (ndom, handlerID);
Marshaller.Free (ndom);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate PrintFuncNative d_g_set_print_handler(PrintFuncNative handler);
static d_g_set_print_handler g_set_print_handler = FuncLoader.LoadFunction<d_g_set_print_handler>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_set_print_handler"));
public static PrintFunc SetPrintHandler (PrintFunc handler)
{
PrintHelper helper = new PrintHelper (handler);
PrintFuncNative prev = g_set_print_handler (helper.Handler);
helper = new PrintHelper (prev);
return helper.Invoker;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate PrintFuncNative d_g_set_printerr_handler(PrintFuncNative handler);
static d_g_set_printerr_handler g_set_printerr_handler = FuncLoader.LoadFunction<d_g_set_printerr_handler>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_set_printerr_handler"));
public static PrintFunc SetPrintErrorHandler (PrintFunc handler)
{
PrintHelper helper = new PrintHelper (handler);
PrintFuncNative prev = g_set_printerr_handler (helper.Handler);
helper = new PrintHelper (prev);
return helper.Invoker;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_log_default_handler(IntPtr log_domain, LogLevelFlags log_level, IntPtr message, IntPtr unused_data);
static d_g_log_default_handler g_log_default_handler = FuncLoader.LoadFunction<d_g_log_default_handler>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_log_default_handler"));
public static void DefaultHandler (string logDomain, LogLevelFlags logLevel, string message)
{
IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
IntPtr nmess = Marshaller.StringToPtrGStrdup (message);
g_log_default_handler (ndom, logLevel, nmess, IntPtr.Zero);
Marshaller.Free (ndom);
Marshaller.Free (nmess);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate LogLevelFlags d_g_log_set_always_fatal(LogLevelFlags fatal_mask);
static d_g_log_set_always_fatal g_log_set_always_fatal = FuncLoader.LoadFunction<d_g_log_set_always_fatal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_log_set_always_fatal"));
public static LogLevelFlags SetAlwaysFatal (LogLevelFlags fatalMask)
{
return g_log_set_always_fatal (fatalMask);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate LogLevelFlags d_g_log_set_fatal_mask(IntPtr log_domain, LogLevelFlags fatal_mask);
static d_g_log_set_fatal_mask g_log_set_fatal_mask = FuncLoader.LoadFunction<d_g_log_set_fatal_mask>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_log_set_fatal_mask"));
public static LogLevelFlags SetAlwaysFatal (string logDomain, LogLevelFlags fatalMask)
{
IntPtr ndom = Marshaller.StringToPtrGStrdup (logDomain);
LogLevelFlags result = g_log_set_fatal_mask (ndom, fatalMask);
Marshaller.Free (ndom);
return result;
}
class Invoker {
LogFuncNative native;
public Invoker (LogFuncNative native)
{
this.native = native;
}
void Invoke (string log_domain, LogLevelFlags flags, string message)
{
IntPtr ndom = Marshaller.StringToPtrGStrdup (log_domain);
IntPtr nmess = Marshaller.StringToPtrGStrdup (message);
native (ndom, flags, nmess, IntPtr.Zero);
Marshaller.Free (ndom);
Marshaller.Free (nmess);
}
public LogFunc Handler {
get { return new LogFunc (Invoke); }
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate LogFuncNative d_g_log_set_default_handler(LogFuncNative log_func, IntPtr user_data);
static d_g_log_set_default_handler g_log_set_default_handler = FuncLoader.LoadFunction<d_g_log_set_default_handler>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_log_set_default_handler"));
public static LogFunc SetDefaultHandler (LogFunc log_func)
{
if (native_handler == null)
native_handler = new LogFuncNative (NativeCallback);
LogFuncNative prev = g_log_set_default_handler (native_handler, (IntPtr) GCHandle.Alloc (log_func));
if (prev == null)
return null;
Invoker invoker = new Invoker (prev);
return invoker.Handler;
}
/*
* Some common logging methods.
*
* Sample usage:
*
* // Print the messages for the NULL domain
* LogFunc logFunc = new LogFunc (Log.PrintLogFunction);
* Log.SetLogHandler (null, LogLevelFlags.All, logFunc);
*
* // Print messages and stack trace for Gtk critical messages
* logFunc = new LogFunc (Log.PrintTraceLogFunction);
* Log.SetLogHandler ("Gtk", LogLevelFlags.Critical, logFunc);
*
*/
public static void PrintLogFunction (string domain, LogLevelFlags level, string message)
{
Console.WriteLine ("Domain: '{0}' Level: {1}", domain, level);
Console.WriteLine ("Message: {0}", message);
}
public static void PrintTraceLogFunction (string domain, LogLevelFlags level, string message)
{
PrintLogFunction (domain, level, message);
Console.WriteLine ("Trace follows:\n{0}", new System.Diagnostics.StackTrace ());
}
}
}

View File

@@ -0,0 +1,168 @@
// GLib.MainContext.cs - mainContext class implementation
//
// Author: Radek Doulik <rodo@matfyz.cz>
//
// Copyright (c) 2003 Radek Doulik
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class MainContext {
IntPtr handle;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_main_context_new();
static d_g_main_context_new g_main_context_new = FuncLoader.LoadFunction<d_g_main_context_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_new"));
public MainContext ()
{
handle = g_main_context_new ();
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_main_context_ref(IntPtr raw);
static d_g_main_context_ref g_main_context_ref = FuncLoader.LoadFunction<d_g_main_context_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_ref"));
public MainContext (IntPtr raw)
{
handle = raw;
g_main_context_ref (handle);
}
public IntPtr Handle {
get {
return handle;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_main_context_unref(IntPtr raw);
static d_g_main_context_unref g_main_context_unref = FuncLoader.LoadFunction<d_g_main_context_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_unref"));
~MainContext ()
{
g_main_context_unref (handle);
handle = IntPtr.Zero;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_main_context_default();
static d_g_main_context_default g_main_context_default = FuncLoader.LoadFunction<d_g_main_context_default>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_default"));
public static MainContext Default {
get {
return new MainContext (g_main_context_default ());
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_main_context_thread_default();
static d_g_main_context_thread_default g_main_context_thread_default = FuncLoader.LoadFunction<d_g_main_context_thread_default>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_thread_default"));
public MainContext ThreadDefault {
get {
IntPtr raw = g_main_context_thread_default ();
// NULL is returned if the thread-default main context is the default context. We'd rather not adopt this strange bahaviour.
return raw == IntPtr.Zero ? Default : new MainContext (raw);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_main_context_push_thread_default(IntPtr raw);
static d_g_main_context_push_thread_default g_main_context_push_thread_default = FuncLoader.LoadFunction<d_g_main_context_push_thread_default>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_push_thread_default"));
public void PushThreadDefault ()
{
g_main_context_push_thread_default (handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_main_context_pop_thread_default(IntPtr raw);
static d_g_main_context_pop_thread_default g_main_context_pop_thread_default = FuncLoader.LoadFunction<d_g_main_context_pop_thread_default>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_pop_thread_default"));
public void PopThreadDefault ()
{
g_main_context_pop_thread_default (handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_main_context_iteration(IntPtr raw, bool may_block);
static d_g_main_context_iteration g_main_context_iteration = FuncLoader.LoadFunction<d_g_main_context_iteration>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_iteration"));
public bool RunIteration (bool may_block)
{
return g_main_context_iteration (handle, may_block);
}
public bool RunIteration ()
{
return RunIteration (false);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_main_context_pending(IntPtr raw);
static d_g_main_context_pending g_main_context_pending = FuncLoader.LoadFunction<d_g_main_context_pending>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_pending"));
public bool HasPendingEvents
{
get {
return g_main_context_pending (handle);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_main_context_wakeup(IntPtr raw);
static d_g_main_context_wakeup g_main_context_wakeup = FuncLoader.LoadFunction<d_g_main_context_wakeup>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_context_wakeup"));
public void Wakeup ()
{
g_main_context_wakeup (handle);
}
public override bool Equals (object o)
{
if (!(o is MainContext))
return false;
return Handle == (o as MainContext).Handle;
}
public override int GetHashCode ()
{
return Handle.GetHashCode ();
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_main_depth();
static d_g_main_depth g_main_depth = FuncLoader.LoadFunction<d_g_main_depth>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_depth"));
public static int Depth {
get { return g_main_depth (); }
}
public static bool Iteration ()
{
return Iteration (false);
}
public static bool Iteration (bool may_block)
{
return Default.RunIteration (may_block);
}
public static bool Pending ()
{
return Default.HasPendingEvents;
}
}
}

View File

@@ -0,0 +1,101 @@
// GLib.MainLoop.cs - g_main_loop class implementation
//
// Author: Jeroen Zwartepoorte <jeroen@xs4all.nl>
//
// Copyright (c) 2004 Jeroen Zwartepoorte
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
using System;
using System.Runtime.InteropServices;
namespace GLib {
public class MainLoop {
private IntPtr handle;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_main_loop_new(IntPtr context, bool isRunning);
static d_g_main_loop_new g_main_loop_new = FuncLoader.LoadFunction<d_g_main_loop_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_loop_new"));
public MainLoop () : this (MainContext.Default) { }
public MainLoop (MainContext context) : this (context, false) { }
public MainLoop (MainContext context, bool is_running)
{
handle = g_main_loop_new (context.Handle, is_running);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_main_loop_unref(IntPtr loop);
static d_g_main_loop_unref g_main_loop_unref = FuncLoader.LoadFunction<d_g_main_loop_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_loop_unref"));
~MainLoop ()
{
g_main_loop_unref (handle);
handle = IntPtr.Zero;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_main_loop_is_running(IntPtr loop);
static d_g_main_loop_is_running g_main_loop_is_running = FuncLoader.LoadFunction<d_g_main_loop_is_running>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_loop_is_running"));
public bool IsRunning {
get {
return g_main_loop_is_running (handle);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_main_loop_run(IntPtr loop);
static d_g_main_loop_run g_main_loop_run = FuncLoader.LoadFunction<d_g_main_loop_run>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_loop_run"));
public void Run ()
{
g_main_loop_run (handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_main_loop_quit(IntPtr loop);
static d_g_main_loop_quit g_main_loop_quit = FuncLoader.LoadFunction<d_g_main_loop_quit>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_loop_quit"));
public void Quit ()
{
g_main_loop_quit (handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_main_loop_get_context(IntPtr loop);
static d_g_main_loop_get_context g_main_loop_get_context = FuncLoader.LoadFunction<d_g_main_loop_get_context>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_main_loop_get_context"));
public MainContext Context {
get {
return new MainContext (g_main_loop_get_context (handle));
}
}
public override bool Equals (object o)
{
if (!(o is MainLoop))
return false;
return handle == (o as MainLoop).handle;
}
public override int GetHashCode ()
{
return handle.GetHashCode ();
}
}
}

View File

@@ -0,0 +1,149 @@
// GLib.ManagedValue.cs : Managed types boxer
//
// Author: Rachel Hestilow <hestilow@ximian.com>
//
// Copyright (c) 2002 Rachel Hestilow
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
using GLib;
internal class ManagedValue {
GCHandle gch;
object instance;
int ref_count = 1;
private ManagedValue (object instance)
{
this.instance = instance;
gch = GCHandle.Alloc (this);
}
IntPtr Handle {
get { return (IntPtr) gch; }
}
object Instance {
get { return instance; }
}
void Ref ()
{
ref_count++;
}
void Unref ()
{
if (--ref_count == 0) {
instance = null;
gch.Free ();
}
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate IntPtr CopyFunc (IntPtr gch);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void FreeFunc (IntPtr gch);
static CopyFunc copy;
static FreeFunc free;
static GType boxed_type = GType.Invalid;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_boxed_type_register_static(IntPtr typename, CopyFunc copy_func, FreeFunc free_func);
static d_g_boxed_type_register_static g_boxed_type_register_static = FuncLoader.LoadFunction<d_g_boxed_type_register_static>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_boxed_type_register_static"));
public static GType GType {
get {
if (boxed_type == GType.Invalid) {
copy = new CopyFunc (Copy);
free = new FreeFunc (Free);
IntPtr name = Marshaller.StringToPtrGStrdup ("GtkSharpValue");
boxed_type = new GLib.GType (g_boxed_type_register_static (name, copy, free));
Marshaller.Free (name);
}
return boxed_type;
}
}
static ManagedValue FromHandle (IntPtr ptr)
{
GCHandle gch = (GCHandle) ptr;
ManagedValue val = gch.Target as ManagedValue;
if (val == null)
throw new Exception ("Unexpected GCHandle received.");
return val;
}
static IntPtr Copy (IntPtr ptr)
{
try {
if (ptr == IntPtr.Zero)
return ptr;
ManagedValue val = FromHandle (ptr);
val.Ref ();
return ptr;
} catch (Exception e) {
ExceptionManager.RaiseUnhandledException (e, false);
}
return IntPtr.Zero;
}
static void Free (IntPtr ptr)
{
try {
if (ptr == IntPtr.Zero)
return;
ManagedValue val = FromHandle (ptr);
val.Unref ();
} catch (Exception e) {
ExceptionManager.RaiseUnhandledException (e, false);
}
}
public static IntPtr WrapObject (object obj)
{
if (obj == null)
return IntPtr.Zero;
return new ManagedValue (obj).Handle;
}
public static object ObjectForWrapper (IntPtr ptr)
{
if (ptr == IntPtr.Zero)
return null;
ManagedValue val = FromHandle (ptr);
return val == null ? null : val.Instance;
}
public static void ReleaseWrapper (IntPtr ptr)
{
if (ptr == IntPtr.Zero)
return;
ManagedValue val = FromHandle (ptr);
val.Unref ();
}
}
}

View File

@@ -0,0 +1,48 @@
// Markup.cs: Wrapper for the Markup code in Glib
//
// Authors:
// Miguel de Icaza (miguel@ximian.com)
//
// Copyright (c) 2003 Ximian, Inc.
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
using System;
using System.Runtime.InteropServices;
namespace GLib {
public class Markup {
private Markup () {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_markup_escape_text(IntPtr text, int len);
static d_g_markup_escape_text g_markup_escape_text = FuncLoader.LoadFunction<d_g_markup_escape_text>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_markup_escape_text"));
static public string EscapeText (string s)
{
if (s == null)
return String.Empty;
IntPtr native = Marshaller.StringToPtrGStrdup (s);
string result = Marshaller.PtrToStringGFree (g_markup_escape_text (native, -1));
Marshaller.Free (native);
return result;
}
}
}

View File

@@ -0,0 +1,50 @@
// 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;
#region Autogenerated code
[StructLayout(LayoutKind.Sequential)]
public partial struct MarkupParser : IEquatable<MarkupParser> {
private IntPtr _start_element;
private IntPtr _end_element;
private IntPtr _text;
private IntPtr _passthrough;
private IntPtr _error;
public static GLib.MarkupParser Zero = new GLib.MarkupParser ();
public static GLib.MarkupParser New(IntPtr raw) {
if (raw == IntPtr.Zero)
return GLib.MarkupParser.Zero;
return (GLib.MarkupParser) Marshal.PtrToStructure (raw, typeof (GLib.MarkupParser));
}
public bool Equals (MarkupParser other)
{
return true && _start_element.Equals (other._start_element) && _end_element.Equals (other._end_element) && _text.Equals (other._text) && _passthrough.Equals (other._passthrough) && _error.Equals (other._error);
}
public override bool Equals (object other)
{
return other is MarkupParser && Equals ((MarkupParser) other);
}
public override int GetHashCode ()
{
return this.GetType ().FullName.GetHashCode () ^ _start_element.GetHashCode () ^ _end_element.GetHashCode () ^ _text.GetHashCode () ^ _passthrough.GetHashCode () ^ _error.GetHashCode ();
}
private static GLib.GType GType {
get { return GLib.GType.Pointer; }
}
#endregion
}
}

View File

@@ -0,0 +1,431 @@
// GLibSharp.Marshaller.cs : Marshalling utils
//
// Author: Rachel Hestilow <rachel@nullenvoid.com>
// Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2002, 2003 Rachel Hestilow
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public class Marshaller {
private Marshaller () {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_free(IntPtr mem);
static d_g_free g_free = FuncLoader.LoadFunction<d_g_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_free"));
public static void Free (IntPtr ptr)
{
g_free (ptr);
}
public static void Free (IntPtr[] ptrs)
{
if (ptrs == null)
return;
for (int i = 0; i < ptrs.Length; i++)
g_free (ptrs [i]);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_filename_to_utf8(IntPtr mem, IntPtr len, IntPtr read, out IntPtr written, out IntPtr error);
static d_g_filename_to_utf8 g_filename_to_utf8 = FuncLoader.LoadFunction<d_g_filename_to_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_filename_to_utf8"));
public static string FilenamePtrToString (IntPtr ptr)
{
if (ptr == IntPtr.Zero) return null;
IntPtr utf8 = g_filename_to_utf8 (ptr, (IntPtr)(-1), IntPtr.Zero, out _, out var error);
if (error != IntPtr.Zero)
throw new GLib.GException (error);
return Utf8PtrToString (utf8);
}
public static string FilenamePtrToStringGFree (IntPtr ptr)
{
string ret = FilenamePtrToString (ptr);
g_free (ptr);
return ret;
}
static unsafe ulong strlen (IntPtr s)
{
ulong cnt = 0;
byte *b = (byte *)s;
while (*b != 0) {
b++;
cnt++;
}
return cnt;
}
public static string Utf8PtrToString (IntPtr ptr)
{
if (ptr == IntPtr.Zero)
return null;
int len = (int) (uint) strlen (ptr);
byte[] bytes = new byte [len];
Marshal.Copy (ptr, bytes, 0, len);
return System.Text.Encoding.UTF8.GetString (bytes);
}
public static string[] Utf8PtrToString (IntPtr[] ptrs) {
// The last pointer is a null terminator.
string[] ret = new string[ptrs.Length - 1];
for (int i = 0; i < ret.Length; i++)
ret[i] = Utf8PtrToString (ptrs[i]);
return ret;
}
public static string PtrToStringGFree (IntPtr ptr)
{
string ret = Utf8PtrToString (ptr);
g_free (ptr);
return ret;
}
public static string[] PtrToStringGFree (IntPtr[] ptrs) {
// The last pointer is a null terminator.
string[] ret = new string[ptrs.Length - 1];
for (int i = 0; i < ret.Length; i++) {
ret[i] = Utf8PtrToString (ptrs[i]);
g_free (ptrs[i]);
}
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_filename_from_utf8(IntPtr mem, IntPtr len, IntPtr read, out IntPtr written, out IntPtr error);
static d_g_filename_from_utf8 g_filename_from_utf8 = FuncLoader.LoadFunction<d_g_filename_from_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_filename_from_utf8"));
public static IntPtr StringToFilenamePtr (string str)
{
if (str == null)
return IntPtr.Zero;
IntPtr utf8 = StringToPtrGStrdup (str);
IntPtr result = g_filename_from_utf8 (utf8, (IntPtr)(-1), IntPtr.Zero, out _, out var error);
g_free (utf8);
if (error != IntPtr.Zero)
throw new GException (error);
return result;
}
public static IntPtr StringToPtrGStrdup (string str) {
if (str == null)
return IntPtr.Zero;
byte[] bytes = System.Text.Encoding.UTF8.GetBytes (str);
IntPtr result = g_malloc (new UIntPtr ((ulong)bytes.Length + 1));
Marshal.Copy (bytes, 0, result, bytes.Length);
Marshal.WriteByte (result, bytes.Length, 0);
return result;
}
public static string StringFormat (string format, params object[] args) {
string ret = String.Format (format, args);
if (ret.IndexOf ('%') == -1)
return ret;
else
return ret.Replace ("%", "%%");
}
public static IntPtr StringArrayToStrvPtr (string[] strs)
{
IntPtr[] ptrs = StringArrayToNullTermPointer (strs);
IntPtr ret = g_malloc (new UIntPtr ((ulong) (ptrs.Length * IntPtr.Size)));
Marshal.Copy (ptrs, 0, ret, ptrs.Length);
return ret;
}
public static IntPtr StringArrayToNullTermStrvPointer (string[] strs)
{
return StringArrayToStrvPtr (strs);
}
public static IntPtr[] StringArrayToNullTermPointer (string[] strs)
{
if (strs == null)
return null;
IntPtr[] result = new IntPtr [strs.Length + 1];
for (int i = 0; i < strs.Length; i++)
result [i] = StringToPtrGStrdup (strs [i]);
result [strs.Length] = IntPtr.Zero;
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_strfreev(IntPtr mem);
static d_g_strfreev g_strfreev = FuncLoader.LoadFunction<d_g_strfreev>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_strfreev"));
public static void StrFreeV (IntPtr null_term_array)
{
g_strfreev (null_term_array);
}
public static string[] NullTermPtrToStringArray (IntPtr null_term_array, bool owned)
{
if (null_term_array == IntPtr.Zero)
return new string [0];
int count = 0;
var result = new List<string> ();
IntPtr s = Marshal.ReadIntPtr (null_term_array, count++ * IntPtr.Size);
while (s != IntPtr.Zero) {
result.Add (Utf8PtrToString (s));
s = Marshal.ReadIntPtr (null_term_array, count++ * IntPtr.Size);
}
if (owned)
g_strfreev (null_term_array);
return result.ToArray ();
}
public static string[] PtrToStringArrayGFree (IntPtr string_array)
{
if (string_array == IntPtr.Zero)
return new string [0];
int count = 0;
while (Marshal.ReadIntPtr (string_array, count*IntPtr.Size) != IntPtr.Zero)
++count;
string[] members = new string[count];
for (int i = 0; i < count; ++i) {
IntPtr s = Marshal.ReadIntPtr (string_array, i * IntPtr.Size);
members[i] = PtrToStringGFree (s);
}
Free (string_array);
return members;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_malloc(UIntPtr size);
static d_g_malloc g_malloc = FuncLoader.LoadFunction<d_g_malloc>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_malloc"));
public static IntPtr Malloc (ulong size)
{
return g_malloc (new UIntPtr (size));
}
static System.DateTime local_epoch = new System.DateTime (1970, 1, 1, 0, 0, 0);
static int utc_offset = (int) (System.TimeZone.CurrentTimeZone.GetUtcOffset (System.DateTime.Now)).TotalSeconds;
public static IntPtr DateTimeTotime_t (System.DateTime time)
{
return new IntPtr (((long)time.Subtract (local_epoch).TotalSeconds) - utc_offset);
}
public static System.DateTime time_tToDateTime (IntPtr time_t)
{
return local_epoch.AddSeconds (time_t.ToInt64 () + utc_offset);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_malloc0(UIntPtr size);
static d_g_malloc0 g_malloc0 = FuncLoader.LoadFunction<d_g_malloc0>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_malloc0"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_unichar_to_utf8(uint c, IntPtr buf);
static d_g_unichar_to_utf8 g_unichar_to_utf8 = FuncLoader.LoadFunction<d_g_unichar_to_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_unichar_to_utf8"));
public static char GUnicharToChar (uint ucs4_char)
{
if (ucs4_char == 0)
return (char) 0;
string ret = GUnicharToString (ucs4_char);
if (ret.Length != 1)
throw new ArgumentOutOfRangeException ("ucs4char is not representable by a char.");
return ret [0];
}
public static string GUnicharToString (uint ucs4_char)
{
if (ucs4_char == 0)
return String.Empty;
IntPtr buf = g_malloc0 (new UIntPtr (7));
g_unichar_to_utf8 (ucs4_char, buf);
return PtrToStringGFree (buf);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_utf16_to_ucs4(ref ushort c, IntPtr len, IntPtr d1, IntPtr d2, IntPtr d3);
static d_g_utf16_to_ucs4 g_utf16_to_ucs4 = FuncLoader.LoadFunction<d_g_utf16_to_ucs4>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_utf16_to_ucs4"));
public static uint CharToGUnichar (char c)
{
ushort val = (ushort) c;
IntPtr ucs4_str = g_utf16_to_ucs4 (ref val, new IntPtr (1), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
uint result = (uint) Marshal.ReadInt32 (ucs4_str);
g_free (ucs4_str);
return result;
}
public static IntPtr StructureToPtrAlloc (object o)
{
IntPtr result = Marshal.AllocHGlobal (Marshal.SizeOf (o));
Marshal.StructureToPtr (o, result, false);
return result;
}
public static IntPtr ArrayToArrayPtr (byte[] array)
{
IntPtr ret = Malloc ((ulong) array.Length);
Marshal.Copy (array, 0, ret, array.Length);
return ret;
}
public static Array ArrayPtrToArray (IntPtr array_ptr, Type element_type, int length, bool owned)
{
Array result = null;
if (element_type == typeof (byte)) {
byte[] ret = new byte [length];
Marshal.Copy (array_ptr, ret, 0, length);
result = ret;
} else {
throw new InvalidOperationException ("Marshaling of " + element_type + " arrays is not supported");
}
if (owned)
Free (array_ptr);
return result;
}
public static byte[] ArrayPtrToArray<TElement> (IntPtr array_ptr, int length, bool owned)
{
byte[] result = null;
if (typeof(TElement) == typeof (byte)) {
byte[] ret = new byte [length];
Marshal.Copy (array_ptr, ret, 0, length);
result = ret;
} else {
throw new InvalidOperationException ("Marshaling of " + typeof(TElement) + " arrays is not supported");
}
if (owned)
Free (array_ptr);
return result;
}
public static Array ListPtrToArray (IntPtr list_ptr, Type list_type, bool owned, bool elements_owned, Type elem_type)
{
Type array_type = elem_type == typeof (ListBase.FilenameString) ? typeof (string) : elem_type;
ListBase list;
if (list_type == typeof(GLib.List))
list = new GLib.List (list_ptr, elem_type, owned, elements_owned);
else
list = new GLib.SList (list_ptr, elem_type, owned, elements_owned);
using (list)
return ListToArray (list, array_type);
}
public static TElement[] ListPtrToArray<TElement, TListElement> (IntPtr list_ptr, bool owned, bool elements_owned)
{
using (GLib.List list = new GLib.List (list_ptr, typeof(TListElement), owned, elements_owned))
return ListToArray<TElement> (list);
}
public static TElement[] SListPtrToArray<TElement, TListElement> (IntPtr list_ptr, bool owned, bool elements_owned)
{
using (GLib.SList list = new GLib.SList (list_ptr, typeof(TListElement), owned, elements_owned))
return ListToArray<TElement> (list);
}
public static Array PtrArrayToArray (IntPtr list_ptr, bool owned, bool elements_owned, Type elem_type)
{
GLib.PtrArray array = new GLib.PtrArray (list_ptr, elem_type, owned, elements_owned);
Array ret = Array.CreateInstance (elem_type, array.Count);
array.CopyTo (ret, 0);
array.Dispose ();
return ret;
}
public static TElement[] PtrArrayToArray<TElement> (IntPtr list_ptr, bool owned, bool elements_owned)
{
GLib.PtrArray array = new GLib.PtrArray (list_ptr, typeof(TElement), owned, elements_owned);
TElement[] ret = new TElement[array.Count];
array.CopyTo (ret, 0);
array.Dispose ();
return ret;
}
public static Array ListToArray (ListBase list, System.Type type)
{
Array result = Array.CreateInstance (type, list.Count);
if (list.Count > 0)
list.CopyTo (result, 0);
if (type.IsSubclassOf (typeof (GLib.Opaque)))
list.elements_owned = false;
return result;
}
public static TElement[] ListToArray<TElement> (ListBase list)
{
TElement[] result = new TElement[list.Count];
if (list.Count > 0)
list.CopyTo (result, 0);
if (typeof(TElement).IsSubclassOf (typeof (GLib.Opaque)))
list.elements_owned = false;
return result;
}
public static T[] StructArrayFromNullTerminatedIntPtr<T> (IntPtr array)
{
var res = new List<T> ();
IntPtr current = array;
T currentStruct = default(T);
while (current != IntPtr.Zero) {
Marshal.PtrToStructure (current, currentStruct);
res.Add (currentStruct);
current = (IntPtr) ((long)current + Marshal.SizeOf<T> ());
}
return res.ToArray ();
}
public static unsafe IntPtr StructArrayToNullTerminatedStructArrayIntPtr<T> (T[] InputArray)
{
int intPtrSize = sizeof (IntPtr);
IntPtr mem = Marshal.AllocHGlobal ((InputArray.Length + 1) * intPtrSize);
for (int i = 0; i < InputArray.Length; i++) {
IntPtr structPtr = Marshal.AllocHGlobal (Marshal.SizeOf<T> ());
Marshal.StructureToPtr (InputArray[i], structPtr, false);
// jump to next pointer
Marshal.WriteIntPtr (mem, structPtr);
mem = (IntPtr) ((long)mem + intPtrSize);
}
// null terminate
Marshal.WriteIntPtr (mem, IntPtr.Zero);
return mem;
}
}
}

View File

@@ -0,0 +1,34 @@
// MissingIntPtrCtorException.cs : Exception for missing IntPtr ctors
//
// Authors: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
public class MissingIntPtrCtorException : Exception
{
public MissingIntPtrCtorException (string msg) : base (msg)
{
}
}
}

View File

@@ -0,0 +1,61 @@
// 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;
#region Autogenerated code
public partial class Mutex : GLib.Opaque {
public struct ABI {
IntPtr p;
int i1;
int i2;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_mutex_clear(IntPtr raw);
static d_g_mutex_clear g_mutex_clear = FuncLoader.LoadFunction<d_g_mutex_clear>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_mutex_clear"));
public void Clear() {
g_mutex_clear(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_mutex_init(IntPtr raw);
static d_g_mutex_init g_mutex_init = FuncLoader.LoadFunction<d_g_mutex_init>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_mutex_init"));
public void Init() {
g_mutex_init(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_mutex_lock(IntPtr raw);
static d_g_mutex_lock g_mutex_lock = FuncLoader.LoadFunction<d_g_mutex_lock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_mutex_lock"));
public void Lock() {
g_mutex_lock(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_mutex_trylock(IntPtr raw);
static d_g_mutex_trylock g_mutex_trylock = FuncLoader.LoadFunction<d_g_mutex_trylock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_mutex_trylock"));
public bool Trylock() {
bool raw_ret = g_mutex_trylock(Handle);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_mutex_unlock(IntPtr raw);
static d_g_mutex_unlock g_mutex_unlock = FuncLoader.LoadFunction<d_g_mutex_unlock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_mutex_unlock"));
public void Unlock() {
g_mutex_unlock(Handle);
}
public Mutex(IntPtr raw) : base(raw) {}
#endregion
}
}

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public delegate void NotifyHandler (object o, NotifyArgs args);
public class NotifyArgs : GLib.SignalArgs {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_get_name(IntPtr pspec);
static d_g_param_spec_get_name g_param_spec_get_name = FuncLoader.LoadFunction<d_g_param_spec_get_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_get_name"));
public string Property {
get {
IntPtr raw_ret = g_param_spec_get_name ((IntPtr) Args[0]);
return Marshaller.Utf8PtrToString (raw_ret);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
// GLib.ObjectManager.cs - GLib ObjectManager class implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// Copyright <c> 2001-2002 Mike Kestner
// Copyright <c> 2004-2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
using System.Reflection;
public static class ObjectManager {
static BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance;
public static GLib.Object CreateObject (IntPtr raw)
{
if (raw == IntPtr.Zero)
return null;
Type type = GetTypeOrParent (raw);
if (type == null)
return null;
GLib.Object obj;
try {
obj = Activator.CreateInstance (type, flags, null, new object[] {raw}, null) as GLib.Object;
} catch (MissingMethodException) {
throw new GLib.MissingIntPtrCtorException ("Unable to construct instance of type " + type + " from native object handle. Instance of managed subclass may have been prematurely disposed.");
}
return obj;
}
[Obsolete ("Replaced by GType.Register (GType, Type)")]
public static void RegisterType (string native_name, string managed_name, string assembly)
{
RegisterType (native_name, managed_name + "," + assembly);
}
[Obsolete ("Replaced by GType.Register (GType, Type)")]
public static void RegisterType (string native_name, string mangled)
{
RegisterType (GType.FromName (native_name), Type.GetType (mangled));
}
[Obsolete ("Replaced by GType.Register (GType, Type)")]
public static void RegisterType (GType native_type, System.Type type)
{
GType.Register (native_type, type);
}
static Type GetTypeOrParent (IntPtr obj)
{
IntPtr typeid = GType.ValFromInstancePtr (obj);
if (typeid == GType.Invalid.Val)
return null;
Type result = GType.LookupType (typeid);
while (result == null) {
typeid = g_type_parent (typeid);
if (typeid == IntPtr.Zero)
return null;
result = GType.LookupType (typeid);
}
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_type_parent(IntPtr typ);
static d_g_type_parent g_type_parent = FuncLoader.LoadFunction<d_g_type_parent>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_parent"));
}
}

View File

@@ -0,0 +1,139 @@
// Opaque .cs - Opaque struct wrapper implementation
//
// Authors: Bob Smith <bob@thestuff.net>
// Mike Kestner <mkestner@speakeasy.net>
// Rachel Hestilow <hestilow@ximian.com>
//
// Copyright (c) 2001 Bob Smith
// Copyright (c) 2001 Mike Kestner
// Copyright (c) 2002 Rachel Hestilow
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
public class Opaque : IWrapper, IDisposable {
IntPtr _obj;
bool owned;
public static Opaque GetOpaque (IntPtr o, Type type, bool owned)
{
if (o == IntPtr.Zero)
return null;
Opaque opaque = (Opaque)Activator.CreateInstance (type, new object[] { o });
if (owned) {
if (opaque.owned) {
// The constructor took a Ref it shouldn't have, so undo it
opaque.Unref (o);
}
opaque.owned = true;
} else
opaque = opaque.Copy (o);
return opaque;
}
public Opaque ()
{
owned = true;
}
public Opaque (IntPtr raw)
{
owned = false;
Raw = raw;
}
protected IntPtr Raw {
get {
return _obj;
}
set {
if (_obj == value) {
return;
}
if (_obj != IntPtr.Zero) {
Unref (_obj);
if (owned)
Free (_obj);
}
_obj = value;
if (_obj != IntPtr.Zero) {
Ref (_obj);
}
}
}
public virtual void Dispose ()
{
Raw = IntPtr.Zero;
GC.SuppressFinalize (this);
}
// These take an IntPtr arg so we don't get conflicts if we need
// to have an "[Obsolete] public void Ref ()"
protected virtual void Ref (IntPtr raw) {}
protected virtual void Unref (IntPtr raw) {}
protected virtual void Free (IntPtr raw) {}
protected virtual Opaque Copy (IntPtr raw)
{
return this;
}
public IntPtr Handle {
get {
return _obj;
}
}
public IntPtr OwnedCopy {
get {
Opaque result = Copy (Handle);
result.Owned = false;
return result.Handle;
}
}
public bool Owned {
get {
return owned;
}
set {
owned = value;
}
}
public override bool Equals (object o)
{
if (!(o is Opaque))
return false;
return (Handle == ((Opaque) o).Handle);
}
public override int GetHashCode ()
{
return Handle.GetHashCode ();
}
}
}

View File

@@ -0,0 +1,206 @@
// ParamSpec.cs - GParamSpec class wrapper implementation
//
// Authors: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2008 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
internal enum ParamFlags {
None = 0,
Readable = 1 << 0,
Writable = 1 << 1,
Construct = 1 << 2,
ConstructOnly = 1 << 3,
}
public class ParamSpec {
IntPtr handle;
public ParamSpec (string name, string nick, string blurb, GType type, bool readable, bool writable) : this (name, nick, blurb, type, (readable ? ParamFlags.Readable : ParamFlags.None) | (writable ? ParamFlags.Writable : ParamFlags.None)) {}
internal ParamSpec (string name, string nick, string blurb, GType type, ParamFlags pflags)
{
int flags = (int) pflags;
IntPtr p_name = GLib.Marshaller.StringToPtrGStrdup (name);
IntPtr p_nick = GLib.Marshaller.StringToPtrGStrdup (nick);
IntPtr p_blurb = GLib.Marshaller.StringToPtrGStrdup (blurb);
if (type == GType.Char)
handle = g_param_spec_char (p_name, p_nick, p_blurb, SByte.MinValue, SByte.MaxValue, 0, flags);
else if (type == GType.UChar)
handle = g_param_spec_uchar (p_name, p_nick, p_blurb, Byte.MinValue, Byte.MaxValue, 0, flags);
else if (type == GType.Boolean)
handle = g_param_spec_boolean (p_name, p_nick, p_blurb, false, flags);
else if (type == GType.Int)
handle = g_param_spec_int (p_name, p_nick, p_blurb, Int32.MinValue, Int32.MaxValue, 0, flags);
else if (type == GType.UInt)
handle = g_param_spec_uint (p_name, p_nick, p_blurb, 0, UInt32.MaxValue, 0, flags);
else if (type == GType.Long)
handle = g_param_spec_long (p_name, p_nick, p_blurb, IntPtr.Zero, IntPtr.Size == 4 ? new IntPtr (Int32.MaxValue) : new IntPtr (Int64.MaxValue), IntPtr.Zero, flags);
else if (type == GType.ULong)
handle = g_param_spec_ulong (p_name, p_nick, p_blurb, UIntPtr.Zero, UIntPtr.Size == 4 ? new UIntPtr (UInt32.MaxValue) : new UIntPtr (UInt64.MaxValue), UIntPtr.Zero, flags);
else if (type == GType.Int64)
handle = g_param_spec_int64 (p_name, p_nick, p_blurb, Int64.MinValue, Int64.MaxValue, 0, flags);
else if (type == GType.UInt64)
handle = g_param_spec_uint64 (p_name, p_nick, p_blurb, 0, UInt64.MaxValue, 0, flags);
else if (type.GetBaseType () == GType.Enum)
handle = g_param_spec_enum (p_name, p_nick, p_blurb, type.Val, (int) (Enum.GetValues((Type)type).GetValue (0)), flags);
/*else if (type == GType.Flags)
* g_param_spec_flags (p_name, p_nick, p_blurb, type.Val, Enum.GetValues((Type)type) [0], flags);
* TODO:
* Both g_param_spec_enum and g_param_spec_flags expect default property values and the members of the enum seemingly cannot be enumerated
*/
else if (type == GType.Float)
handle = g_param_spec_float (p_name, p_nick, p_blurb, Single.MinValue, Single.MaxValue, 0.0f, flags);
else if (type == GType.Double)
handle = g_param_spec_double (p_name, p_nick, p_blurb, Double.MinValue, Double.MaxValue, 0.0, flags);
else if (type == GType.String)
handle = g_param_spec_string (p_name, p_nick, p_blurb, IntPtr.Zero, flags);
else if (type == GType.Pointer)
handle = g_param_spec_pointer (p_name, p_nick, p_blurb, flags);
else if (type.Val == g_gtype_get_type ())
handle = g_param_spec_gtype (p_name, p_nick, p_blurb, GType.None.Val, flags);
else if (g_type_is_a (type.Val, GType.Boxed.Val))
handle = g_param_spec_boxed (p_name, p_nick, p_blurb, type.Val, flags);
else if (g_type_is_a (type.Val, GType.Object.Val))
handle = g_param_spec_object (p_name, p_nick, p_blurb, type.Val, flags);
else
throw new ArgumentException ("type:" + type.ToString ());
GLib.Marshaller.Free (p_name);
GLib.Marshaller.Free (p_nick);
GLib.Marshaller.Free (p_blurb);
}
public ParamSpec (IntPtr native)
{
handle = native;
}
public IntPtr Handle {
get { return handle; }
}
public GType ValueType {
get {
GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec));
return new GType (spec.value_type);
}
}
public string Name {
get {
GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec));
return Marshaller.Utf8PtrToString (spec.name);
}
}
public override string ToString ()
{
GParamSpec spec = (GParamSpec) Marshal.PtrToStructure (Handle, typeof (GParamSpec));
GType valtype= new GType (spec.value_type);
GType ownertype= new GType (spec.owner_type);
return "ParamSpec: name=" + Marshaller.Utf8PtrToString (spec.name) + " value_type=" + valtype.ToString() + " owner_type=" + ownertype.ToString();
}
struct GTypeInstance {
public IntPtr g_class;
}
struct GParamSpec {
public GTypeInstance g_type_instance;
public IntPtr name;
public ParamFlags flags;
public IntPtr value_type;
public IntPtr owner_type;
public IntPtr _nick;
public IntPtr _blurb;
public IntPtr qdata;
public uint ref_count;
public uint param_id;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_char(IntPtr name, IntPtr nick, IntPtr blurb, sbyte min, sbyte max, sbyte dval, int flags);
static d_g_param_spec_char g_param_spec_char = FuncLoader.LoadFunction<d_g_param_spec_char>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_char"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_uchar(IntPtr name, IntPtr nick, IntPtr blurb, byte min, byte max, byte dval, int flags);
static d_g_param_spec_uchar g_param_spec_uchar = FuncLoader.LoadFunction<d_g_param_spec_uchar>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_uchar"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_boolean(IntPtr name, IntPtr nick, IntPtr blurb, bool dval, int flags);
static d_g_param_spec_boolean g_param_spec_boolean = FuncLoader.LoadFunction<d_g_param_spec_boolean>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_boolean"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_enum(IntPtr name, IntPtr nick, IntPtr blurb, IntPtr enum_type, int dval, int flags);
static d_g_param_spec_enum g_param_spec_enum = FuncLoader.LoadFunction<d_g_param_spec_enum>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_enum"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_int(IntPtr name, IntPtr nick, IntPtr blurb, int min, int max, int dval, int flags);
static d_g_param_spec_int g_param_spec_int = FuncLoader.LoadFunction<d_g_param_spec_int>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_int"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_uint(IntPtr name, IntPtr nick, IntPtr blurb, uint min, uint max, uint dval, int flags);
static d_g_param_spec_uint g_param_spec_uint = FuncLoader.LoadFunction<d_g_param_spec_uint>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_uint"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_long(IntPtr name, IntPtr nick, IntPtr blurb, IntPtr min, IntPtr max, IntPtr dval, int flags);
static d_g_param_spec_long g_param_spec_long = FuncLoader.LoadFunction<d_g_param_spec_long>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_long"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_ulong(IntPtr name, IntPtr nick, IntPtr blurb, UIntPtr min, UIntPtr max, UIntPtr dval, int flags);
static d_g_param_spec_ulong g_param_spec_ulong = FuncLoader.LoadFunction<d_g_param_spec_ulong>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_ulong"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_int64(IntPtr name, IntPtr nick, IntPtr blurb, long min, long max, long dval, int flags);
static d_g_param_spec_int64 g_param_spec_int64 = FuncLoader.LoadFunction<d_g_param_spec_int64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_int64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_uint64(IntPtr name, IntPtr nick, IntPtr blurb, ulong min, ulong max, ulong dval, int flags);
static d_g_param_spec_uint64 g_param_spec_uint64 = FuncLoader.LoadFunction<d_g_param_spec_uint64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_uint64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_float(IntPtr name, IntPtr nick, IntPtr blurb, float min, float max, float dval, int flags);
static d_g_param_spec_float g_param_spec_float = FuncLoader.LoadFunction<d_g_param_spec_float>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_float"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_double(IntPtr name, IntPtr nick, IntPtr blurb, double min, double max, double dval, int flags);
static d_g_param_spec_double g_param_spec_double = FuncLoader.LoadFunction<d_g_param_spec_double>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_double"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_string(IntPtr name, IntPtr nick, IntPtr blurb, IntPtr dval, int flags);
static d_g_param_spec_string g_param_spec_string = FuncLoader.LoadFunction<d_g_param_spec_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_string"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_pointer(IntPtr name, IntPtr nick, IntPtr blurb, int flags);
static d_g_param_spec_pointer g_param_spec_pointer = FuncLoader.LoadFunction<d_g_param_spec_pointer>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_pointer"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_gtype(IntPtr name, IntPtr nick, IntPtr blurb, IntPtr dval, int flags);
static d_g_param_spec_gtype g_param_spec_gtype = FuncLoader.LoadFunction<d_g_param_spec_gtype>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_gtype"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_boxed(IntPtr name, IntPtr nick, IntPtr blurb, IntPtr return_type, int flags);
static d_g_param_spec_boxed g_param_spec_boxed = FuncLoader.LoadFunction<d_g_param_spec_boxed>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_boxed"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_param_spec_object(IntPtr name, IntPtr nick, IntPtr blurb, IntPtr return_type, int flags);
static d_g_param_spec_object g_param_spec_object = FuncLoader.LoadFunction<d_g_param_spec_object>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_param_spec_object"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_gtype_get_type();
static d_g_gtype_get_type g_gtype_get_type = FuncLoader.LoadFunction<d_g_gtype_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_gtype_get_type"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_type_is_a(IntPtr a, IntPtr b);
static d_g_type_is_a g_type_is_a = FuncLoader.LoadFunction<d_g_type_is_a>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_is_a"));
}
}

View File

@@ -0,0 +1,68 @@
// 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;
#region Autogenerated code
[StructLayout(LayoutKind.Sequential)]
public partial struct PollFD : IEquatable<PollFD> {
public int Fd;
public ushort Events;
public ushort Revents;
public static GLib.PollFD Zero = new GLib.PollFD ();
public static GLib.PollFD New(IntPtr raw) {
if (raw == IntPtr.Zero)
return GLib.PollFD.Zero;
return (GLib.PollFD) Marshal.PtrToStructure (raw, typeof (GLib.PollFD));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_pollfd_get_type();
static d_g_pollfd_get_type g_pollfd_get_type = FuncLoader.LoadFunction<d_g_pollfd_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_pollfd_get_type"));
public static GLib.GType GType {
get {
IntPtr raw_ret = g_pollfd_get_type();
GLib.GType ret = new GLib.GType(raw_ret);
return ret;
}
}
public bool Equals (PollFD other)
{
return true && Fd.Equals (other.Fd) && Events.Equals (other.Events) && Revents.Equals (other.Revents);
}
public override bool Equals (object other)
{
return other is PollFD && Equals ((PollFD) other);
}
public override int GetHashCode ()
{
return this.GetType().FullName.GetHashCode() ^ Fd.GetHashCode () ^ Events.GetHashCode () ^ Revents.GetHashCode ();
}
public static explicit operator GLib.Value (GLib.PollFD boxed)
{
GLib.Value val = GLib.Value.Empty;
val.Init (GLib.PollFD.GType);
val.Val = boxed;
return val;
}
public static explicit operator GLib.PollFD (GLib.Value val)
{
return (GLib.PollFD) val.Val;
}
#endregion
}
}

View File

@@ -0,0 +1,31 @@
// GLib.Priority.cs
//
// Author(s):
// Stephane Delcroix <stephane@delcroix.org>
//
// Copyright (c) 2009 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
public enum Priority
{
High = -100,
Default = 0,
HighIdle = 100,
DefaultIdle = 200,
Low = 300,
}
}

View File

@@ -0,0 +1,69 @@
// PropertyAttribute.cs
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
public sealed class PropertyAttribute : Attribute {
string blurb;
string nickname;
string name;
public PropertyAttribute (string name)
{
this.name = name;
}
public PropertyAttribute (string name, string nickname, string blurb)
{
this.name = name;
this.nickname = nickname;
this.blurb = blurb;
}
public string Blurb {
get {
return blurb;
}
set {
blurb = value;
}
}
public string Name {
get {
return name;
}
set {
name = value;
}
}
public string Nickname {
get {
return nickname;
}
set {
nickname = value;
}
}
}
}

View File

@@ -0,0 +1,270 @@
// PtrArray.cs - PtrArray wrapper implementation
//
// Authors: Mike Gorse <mgorse@novell.com>
//
// Copyright (c) 2008 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections;
using System.Runtime.InteropServices;
public class PtrArray : IDisposable, ICollection, ICloneable, IWrapper {
private IntPtr handle = IntPtr.Zero;
private bool managed = false;
internal bool elements_owned = false;
protected System.Type element_type = null;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_ptr_array_sized_new(uint n_preallocs);
static d_g_ptr_array_sized_new g_ptr_array_sized_new = FuncLoader.LoadFunction<d_g_ptr_array_sized_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_ptr_array_sized_new"));
public PtrArray (uint n_preallocs, System.Type element_type, bool owned, bool elements_owned)
{
handle = g_ptr_array_sized_new (n_preallocs);
this.element_type = element_type;
managed = owned;
this.elements_owned = elements_owned;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_ptr_array_new();
static d_g_ptr_array_new g_ptr_array_new = FuncLoader.LoadFunction<d_g_ptr_array_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_ptr_array_new"));
public PtrArray (System.Type element_type, bool owned, bool elements_owned)
{
handle = g_ptr_array_new ();
this.element_type = element_type;
managed = owned;
this.elements_owned = elements_owned;
}
internal PtrArray (IntPtr raw, System.Type element_type, bool owned, bool elements_owned)
{
handle = raw;
this.element_type = element_type;
managed = owned;
this.elements_owned = elements_owned;
}
public PtrArray (IntPtr raw, System.Type element_type) : this (raw, element_type, false, false) {}
public PtrArray (IntPtr raw) : this (raw, null) {}
~PtrArray ()
{
Dispose (false);
}
// IDisposable
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_ptr_array_free(IntPtr raw, bool free_seg);
static d_g_ptr_array_free g_ptr_array_free = FuncLoader.LoadFunction<d_g_ptr_array_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_ptr_array_free"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_object_unref(IntPtr item);
static d_g_object_unref g_object_unref = FuncLoader.LoadFunction<d_g_object_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_object_unref"));
void Dispose (bool disposing)
{
if (Handle == IntPtr.Zero)
return;
if (elements_owned) {
int count = Count;
for (uint i = 0; i < count; i++)
if (typeof (GLib.Object).IsAssignableFrom (element_type))
g_object_unref (NthData (i));
else if (typeof (GLib.Opaque).IsAssignableFrom (element_type))
GLib.Opaque.GetOpaque (NthData (i), element_type, true).Dispose ();
else
Marshaller.Free (NthData (i));
}
if (managed)
g_ptr_array_free (Handle, true);
handle = IntPtr.Zero;
}
public IntPtr Handle {
get {
return handle;
}
}
public IntPtr ArrayPtr {
get {
return Marshal.ReadIntPtr (Handle);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_ptr_array_add(IntPtr raw, IntPtr val);
static d_g_ptr_array_add g_ptr_array_add = FuncLoader.LoadFunction<d_g_ptr_array_add>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_ptr_array_add"));
public void Add (IntPtr val)
{
g_ptr_array_add (Handle, val);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_ptr_array_remove(IntPtr raw, IntPtr data);
static d_g_ptr_array_remove g_ptr_array_remove = FuncLoader.LoadFunction<d_g_ptr_array_remove>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_ptr_array_remove"));
public void Remove (IntPtr data)
{
g_ptr_array_remove (Handle, data);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_ptr_array_remove_range(IntPtr raw, uint index, uint length);
static d_g_ptr_array_remove_range g_ptr_array_remove_range = FuncLoader.LoadFunction<d_g_ptr_array_remove_range>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_ptr_array_remove_range"));
public void RemoveRange (IntPtr data, uint index, uint length)
{
g_ptr_array_remove_range (Handle, index, length);
}
struct GPtrArray {
public IntPtr pdata;
public uint len;
}
// ICollection
public int Count {
get {
GPtrArray native = (GPtrArray) Marshal.PtrToStructure (Handle, typeof (GPtrArray));
return (int) native.len;
}
}
public object this [int index] {
get {
IntPtr data = NthData ((uint) index);
object ret = null;
ret = DataMarshal (data);
return ret;
}
}
internal object DataMarshal (IntPtr data)
{
object ret = null;
if (element_type != null) {
if (element_type == typeof (string))
ret = Marshaller.Utf8PtrToString (data);
else if (element_type == typeof (IntPtr))
ret = data;
else if (element_type.IsSubclassOf (typeof (GLib.Object)))
ret = GLib.Object.GetObject (data, false);
else if (element_type.IsSubclassOf (typeof (GLib.Opaque)))
ret = GLib.Opaque.GetOpaque (data, element_type, elements_owned);
else if (element_type == typeof (int))
ret = (int) data;
else if (element_type.IsValueType)
ret = Marshal.PtrToStructure (data, element_type);
else
ret = Activator.CreateInstance (element_type, new object[] {data});
} else if (Object.IsObject (data))
ret = GLib.Object.GetObject (data, false);
return ret;
}
internal IntPtr NthData (uint index)
{
return Marshal.ReadIntPtr (ArrayPtr, (int) index * IntPtr.Size);;
}
// Synchronization could be tricky here. Hmm.
public bool IsSynchronized {
get { return false; }
}
public object SyncRoot {
get { return null; }
}
public void CopyTo (Array array, int index)
{
if (array == null)
throw new ArgumentNullException ("Array can't be null.");
if (index < 0)
throw new ArgumentOutOfRangeException ("Index must be greater than 0.");
if (index + Count < array.Length)
throw new ArgumentException ("Array not large enough to copy into starting at index.");
for (int i = 0; i < Count; i++)
((IList) array) [index + i] = this [i];
}
private class ListEnumerator : IEnumerator
{
private int current = -1;
private PtrArray vals;
public ListEnumerator (PtrArray vals)
{
this.vals = vals;
}
public object Current {
get {
if (current == -1)
return null;
return vals [current];
}
}
public bool MoveNext ()
{
if (++current >= vals.Count) {
current = -1;
return false;
}
return true;
}
public void Reset ()
{
current = -1;
}
}
// IEnumerable
public IEnumerator GetEnumerator ()
{
return new ListEnumerator (this);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_ptr_array_copy(IntPtr raw);
static d_g_ptr_array_copy g_ptr_array_copy = FuncLoader.LoadFunction<d_g_ptr_array_copy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_ptr_array_copy"));
// ICloneable
public object Clone ()
{
return new PtrArray (g_ptr_array_copy (Handle), element_type, false, false);
}
}
}

View File

@@ -0,0 +1,63 @@
// 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;
#region Autogenerated code
public partial class RecMutex : GLib.Opaque {
[StructLayout(LayoutKind.Sequential)]
public struct ABI {
IntPtr p;
int i1;
int i2;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_rec_mutex_clear(IntPtr raw);
static d_g_rec_mutex_clear g_rec_mutex_clear = FuncLoader.LoadFunction<d_g_rec_mutex_clear>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_rec_mutex_clear"));
public void Clear() {
g_rec_mutex_clear(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_rec_mutex_init(IntPtr raw);
static d_g_rec_mutex_init g_rec_mutex_init = FuncLoader.LoadFunction<d_g_rec_mutex_init>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_rec_mutex_init"));
public void Init() {
g_rec_mutex_init(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_rec_mutex_lock(IntPtr raw);
static d_g_rec_mutex_lock g_rec_mutex_lock = FuncLoader.LoadFunction<d_g_rec_mutex_lock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_rec_mutex_lock"));
public void Lock() {
g_rec_mutex_lock(Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_rec_mutex_trylock(IntPtr raw);
static d_g_rec_mutex_trylock g_rec_mutex_trylock = FuncLoader.LoadFunction<d_g_rec_mutex_trylock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_rec_mutex_trylock"));
public bool Trylock() {
bool raw_ret = g_rec_mutex_trylock(Handle);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_rec_mutex_unlock(IntPtr raw);
static d_g_rec_mutex_unlock g_rec_mutex_unlock = FuncLoader.LoadFunction<d_g_rec_mutex_unlock>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_rec_mutex_unlock"));
public void Unlock() {
g_rec_mutex_unlock(Handle);
}
public RecMutex(IntPtr raw) : base(raw) {}
#endregion
}
}

View File

@@ -0,0 +1,102 @@
// SList.cs - GSList class wrapper implementation
//
// Authors: Mike Kestner <mkestner@speakeasy.net>
//
// Copyright (c) 2002 Mike Kestner
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class SList : ListBase {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_slist_copy(IntPtr l);
static d_g_slist_copy g_slist_copy = FuncLoader.LoadFunction<d_g_slist_copy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_slist_copy"));
public override object Clone ()
{
return new SList (g_slist_copy (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_slist_length(IntPtr l);
static d_g_slist_length g_slist_length = FuncLoader.LoadFunction<d_g_slist_length>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_slist_length"));
internal override int Length (IntPtr list)
{
return g_slist_length (list);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_slist_free(IntPtr l);
static d_g_slist_free g_slist_free = FuncLoader.LoadFunction<d_g_slist_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_slist_free"));
internal override void Free (IntPtr list)
{
if (list != IntPtr.Zero)
g_slist_free (list);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_slist_append(IntPtr l, IntPtr raw);
static d_g_slist_append g_slist_append = FuncLoader.LoadFunction<d_g_slist_append>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_slist_append"));
internal override IntPtr Append (IntPtr list, IntPtr raw)
{
return g_slist_append (list, raw);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_slist_prepend(IntPtr l, IntPtr raw);
static d_g_slist_prepend g_slist_prepend = FuncLoader.LoadFunction<d_g_slist_prepend>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_slist_prepend"));
internal override IntPtr Prepend (IntPtr list, IntPtr raw)
{
return g_slist_prepend (list, raw);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_slist_nth_data(IntPtr l, uint n);
static d_g_slist_nth_data g_slist_nth_data = FuncLoader.LoadFunction<d_g_slist_nth_data>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_slist_nth_data"));
internal override IntPtr NthData (uint n)
{
return g_slist_nth_data (Handle, n);
}
public SList (IntPtr raw) : this (raw, null) {}
public SList (System.Type element_type) : this (IntPtr.Zero, element_type) {}
public SList (IntPtr raw, System.Type element_type) : this (raw, element_type, false, false) {}
public SList (IntPtr raw, System.Type element_type, bool owned, bool elements_owned) : base (raw, element_type, owned, elements_owned) {}
public SList (object[] members, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned)
{
foreach (object o in members)
Append (o);
}
public SList (Array members, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned)
{
foreach (object o in members)
Append (o);
}
}
}

View File

@@ -0,0 +1,396 @@
// GLib.Signal.cs - signal marshaling class
//
// Authors: Mike Kestner <mkestner@novell.com>
// Andrés G. Aragoneses <aaragoneses@novell.com>
//
// Copyright (c) 2005,2008 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
[Flags]
public enum ConnectFlags {
After = 1 << 0,
Swapped = 1 << 1,
}
public class Signal {
[Flags]
public enum Flags {
RunFirst = 1 << 0,
RunLast = 1 << 1,
RunCleanup = 1 << 2,
NoRecurse = 1 << 3,
Detailed = 1 << 4,
Action = 1 << 5,
NoHooks = 1 << 6
}
[StructLayout (LayoutKind.Sequential)]
public struct InvocationHint {
public uint signal_id;
public uint detail;
public Flags run_type;
}
[StructLayout (LayoutKind.Sequential)]
struct Query {
public uint signal_id;
public IntPtr signal_name;
public IntPtr itype;
public Flags signal_flags;
public IntPtr return_type;
public uint n_params;
public IntPtr param_types;
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
public delegate bool EmissionHookNative (ref InvocationHint hint, uint n_pvals, IntPtr pvals, IntPtr data);
public delegate bool EmissionHook (InvocationHint ihint, object[] inst_and_param_values);
public class EmissionHookMarshaler {
EmissionHook handler;
EmissionHookNative cb;
IntPtr user_data;
GCHandle gch;
public EmissionHookMarshaler (EmissionHook handler)
{
this.handler = handler;
cb = new EmissionHookNative (NativeCallback);
gch = GCHandle.Alloc (this);
}
public EmissionHookMarshaler (EmissionHookNative callback, IntPtr user_data)
{
cb = callback;
this.user_data = user_data;
handler = new EmissionHook (NativeInvoker);
}
bool NativeCallback (ref InvocationHint hint, uint n_pvals, IntPtr pvals_ptr, IntPtr data)
{
object[] pvals = new object [n_pvals];
for (int i = 0; i < n_pvals; i++) {
IntPtr p = new IntPtr ((long) pvals_ptr + i * Marshal.SizeOf<Value> ());
Value v = (Value) Marshal.PtrToStructure (p, typeof (Value));
pvals [i] = v.Val;
}
bool result = handler (hint, pvals);
if (!result)
gch.Free ();
return result;
}
public EmissionHookNative Callback {
get {
return cb;
}
}
bool NativeInvoker (InvocationHint ihint, object[] pvals)
{
int val_sz = Marshal.SizeOf<Value> ();
IntPtr buf = Marshal.AllocHGlobal (pvals.Length * val_sz);
Value[] vals = new Value [pvals.Length];
for (int i = 0; i < pvals.Length; i++) {
vals [i] = new Value (pvals [i]);
IntPtr p = new IntPtr ((long) buf + i * val_sz);
Marshal.StructureToPtr (vals [i], p, false);
}
bool result = cb (ref ihint, (uint) pvals.Length, buf, user_data);
foreach (Value v in vals)
v.Dispose ();
Marshal.FreeHGlobal (buf);
return result;
}
public EmissionHook Invoker {
get {
return handler;
}
}
}
GLib.Object obj;
string name;
Type args_type;
SignalClosure before_closure;
SignalClosure after_closure;
Delegate after_handler;
Delegate before_handler;
Delegate marshaler;
internal Signal (GLib.Object obj, string name, Delegate marshaler)
{
this.obj = obj;
this.name = name;
this.marshaler = marshaler;
}
internal Signal (GLib.Object obj, string name, Type args_type)
{
this.obj = obj;
this.name = name;
this.args_type = args_type;
}
internal void Free ()
{
if (before_closure != null)
before_closure.Dispose ();
if (after_closure != null)
after_closure.Dispose ();
GC.SuppressFinalize (this);
}
void ClosureDisposedCB (object o, EventArgs args)
{
if (o == before_closure) {
before_closure.Disposed -= new EventHandler (ClosureDisposedHandler);
before_closure.Invoked -= new ClosureInvokedHandler (ClosureInvokedCB);
before_closure = null;
before_handler = null;
} else if (o == after_closure) {
after_closure.Disposed -= new EventHandler (ClosureDisposedHandler);
after_closure.Invoked -= new ClosureInvokedHandler (ClosureInvokedCB);
after_closure = null;
after_handler = null;
}
}
EventHandler closure_disposed_cb;
EventHandler ClosureDisposedHandler {
get {
if (closure_disposed_cb == null)
closure_disposed_cb = new EventHandler (ClosureDisposedCB);
return closure_disposed_cb;
}
}
void ClosureInvokedCB (object o, ClosureInvokedArgs args)
{
Delegate handler;
if (o == before_closure)
handler = before_handler;
else
handler = after_handler;
if (handler != null)
handler.DynamicInvoke (new object[] {args.Target, args.Args});
}
ClosureInvokedHandler closure_invoked_cb;
ClosureInvokedHandler ClosureInvokedHandler {
get {
if (closure_invoked_cb == null)
closure_invoked_cb = new ClosureInvokedHandler (ClosureInvokedCB);
return closure_invoked_cb;
}
}
public Delegate Handler {
get {
var hint = (InvocationHint) Marshal.PtrToStructure (g_signal_get_invocation_hint (obj.Handle), typeof (InvocationHint));
return hint.run_type.HasFlag(Flags.RunFirst)
? before_handler
: after_handler;
}
}
public void AddDelegate (Delegate d)
{
if (args_type == null)
args_type = d.Method.GetParameters ()[1].ParameterType;
if (d.Method.IsDefined (typeof (ConnectBeforeAttribute), false)) {
before_handler = Delegate.Combine (before_handler, d);
if (before_closure == null) {
if (marshaler == null)
before_closure = new SignalClosure (obj.Handle, name, args_type);
else
before_closure = new SignalClosure (obj.Handle, name, marshaler, this);
before_closure.Disposed += ClosureDisposedHandler;
before_closure.Invoked += ClosureInvokedHandler;
before_closure.Connect (false);
}
} else {
after_handler = Delegate.Combine (after_handler, d);
if (after_closure == null) {
if (marshaler == null)
after_closure = new SignalClosure (obj.Handle, name, args_type);
else
after_closure = new SignalClosure (obj.Handle, name, marshaler, this);
after_closure.Disposed += ClosureDisposedHandler;
after_closure.Invoked += ClosureInvokedHandler;
after_closure.Connect (true);
}
}
}
public void RemoveDelegate (Delegate d)
{
if (d.Method.IsDefined (typeof (ConnectBeforeAttribute), false)) {
before_handler = Delegate.Remove (before_handler, d);
if (before_handler == null && before_closure != null) {
before_closure.Dispose ();
before_closure = null;
}
} else {
after_handler = Delegate.Remove (after_handler, d);
if (after_handler == null && after_closure != null) {
after_closure.Dispose ();
after_closure = null;
}
}
}
// format: children-changed::add
private static void ParseSignalDetail (string signal_detail, out string signal_name, out uint gquark)
{
//can't use String.Split because it doesn't accept a string arg (only char) in the 1.x profile
int link_pos = signal_detail.IndexOf ("::");
if (link_pos < 0) {
gquark = 0;
signal_name = signal_detail;
} else if (link_pos == 0) {
throw new FormatException ("Invalid detailed signal: " + signal_detail);
} else {
signal_name = signal_detail.Substring (0, link_pos);
gquark = GetGQuarkFromString (signal_detail.Substring (link_pos + 2));
}
}
public static object Emit (GLib.Object instance, string detailed_signal, params object[] args)
{
uint gquark, signal_id;
string signal_name;
ParseSignalDetail (detailed_signal, out signal_name, out gquark);
signal_id = GetSignalId (signal_name, instance);
if (signal_id <= 0)
throw new ArgumentException ("Invalid signal name: " + signal_name);
GLib.Value[] vals = new GLib.Value [args.Length + 1];
GLib.ValueArray inst_and_params = new GLib.ValueArray ((uint) args.Length + 1);
vals [0] = new GLib.Value (instance);
inst_and_params.Append (vals [0]);
for (int i = 1; i < vals.Length; i++) {
vals [i] = new GLib.Value (args [i - 1]);
inst_and_params.Append (vals [i]);
}
object ret_obj = null;
Query query;
g_signal_query (signal_id, out query);
if (query.return_type != GType.None.Val) {
GLib.Value ret = GLib.Value.Empty;
g_signal_emitv (inst_and_params.ArrayPtr, signal_id, gquark, ref ret);
ret_obj = ret.Val;
ret.Dispose ();
} else
g_signal_emitv2 (inst_and_params.ArrayPtr, signal_id, gquark, IntPtr.Zero);
foreach (GLib.Value val in vals)
val.Dispose ();
return ret_obj;
}
private static uint GetGQuarkFromString (string str) {
IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup (str);
uint ret = g_quark_from_string (native_string);
GLib.Marshaller.Free (native_string);
return ret;
}
private static uint GetSignalId (string signal_name, GLib.Object obj)
{
IntPtr typeid = GType.ValFromInstancePtr (obj.Handle);
return GetSignalId (signal_name, typeid);
}
private static uint GetSignalId (string signal_name, IntPtr typeid)
{
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (signal_name);
uint signal_id = g_signal_lookup (native_name, typeid);
GLib.Marshaller.Free (native_name);
return signal_id;
}
public static ulong AddEmissionHook (string detailed_signal, GLib.GType type, EmissionHook handler_func)
{
uint gquark;
string signal_name;
ParseSignalDetail (detailed_signal, out signal_name, out gquark);
uint signal_id = GetSignalId (signal_name, type.Val);
if (signal_id <= 0)
throw new Exception ("Invalid signal name: " + signal_name);
return g_signal_add_emission_hook (signal_id, gquark, new EmissionHookMarshaler (handler_func).Callback, IntPtr.Zero, IntPtr.Zero);
}
internal static void OverrideDefaultHandler (GType gtype, string name, Delegate cb)
{
IntPtr closure = g_cclosure_new (cb, IntPtr.Zero, IntPtr.Zero);
gtype.EnsureClass ();
uint id = GetSignalId (name, gtype.Val);
g_signal_override_class_closure (id, gtype.Val, closure);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_cclosure_new(Delegate cb, IntPtr data, IntPtr notify);
static d_g_cclosure_new g_cclosure_new = FuncLoader.LoadFunction<d_g_cclosure_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_cclosure_new"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_signal_get_invocation_hint(IntPtr instance);
static d_g_signal_get_invocation_hint g_signal_get_invocation_hint = FuncLoader.LoadFunction<d_g_signal_get_invocation_hint>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_get_invocation_hint"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_signal_emitv(IntPtr instance_and_params, uint signal_id, uint gquark_detail, ref GLib.Value return_value);
static d_g_signal_emitv g_signal_emitv = FuncLoader.LoadFunction<d_g_signal_emitv>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_emitv"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_signal_emitv2(IntPtr instance_and_params, uint signal_id, uint gquark_detail, IntPtr return_value);
static d_g_signal_emitv2 g_signal_emitv2 = FuncLoader.LoadFunction<d_g_signal_emitv2>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_emitv"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_signal_lookup(IntPtr name, IntPtr itype);
static d_g_signal_lookup g_signal_lookup = FuncLoader.LoadFunction<d_g_signal_lookup>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_lookup"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_signal_override_class_closure(uint id, IntPtr gtype, IntPtr closure);
static d_g_signal_override_class_closure g_signal_override_class_closure = FuncLoader.LoadFunction<d_g_signal_override_class_closure>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_override_class_closure"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_signal_query(uint signal_id, out Query query);
static d_g_signal_query g_signal_query = FuncLoader.LoadFunction<d_g_signal_query>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_query"));
//better not to expose g_quark_from_static_string () due to memory allocation issues
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_quark_from_string(IntPtr str);
static d_g_quark_from_string g_quark_from_string = FuncLoader.LoadFunction<d_g_quark_from_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_quark_from_string"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate ulong d_g_signal_add_emission_hook(uint signal_id, uint gquark_detail, EmissionHookNative hook_func, IntPtr hook_data, IntPtr data_destroy);
static d_g_signal_add_emission_hook g_signal_add_emission_hook = FuncLoader.LoadFunction<d_g_signal_add_emission_hook>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_add_emission_hook"));
}
}

View File

@@ -0,0 +1,67 @@
// GLib.SignalArgs.cs - Signal argument class implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// Copyright (c) 2001 Mike Kestner
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
public class SignalArgs : EventArgs {
private object _ret;
private object[] _args;
public SignalArgs()
{
_ret = null;
_args = null;
}
public SignalArgs(object retval)
{
_ret = retval;
_args = null;
}
public SignalArgs(object retval, object[] args)
{
_ret = retval;
_args = args;
}
public object[] Args {
get {
return _args;
}
set {
_args = value;
}
}
public object RetVal {
get {
return _ret;
}
set {
_ret = value;
}
}
}
}

View File

@@ -0,0 +1,47 @@
// SignalAttribute.cs
//
// Author:
// Ricardo Fern<72>ndez Pascual <ric@users.sourceforge.net>
//
// Copyright (c) Ricardo Fern<72>ndez Pascual <ric@users.sourceforge.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
[Serializable]
[AttributeUsage (AttributeTargets.Event, Inherited=false)]
public sealed class SignalAttribute : Attribute
{
private string cname;
public SignalAttribute (string cname)
{
this.cname = cname;
}
private SignalAttribute () {}
public string CName
{
get {
return cname;
}
}
}
}

View File

@@ -0,0 +1,227 @@
// SignalClosure.cs - signal marshaling class
//
// Authors: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2008 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections;
using System.Runtime.InteropServices;
internal class ClosureInvokedArgs : EventArgs {
EventArgs args;
GLib.Object obj;
public ClosureInvokedArgs (GLib.Object obj, EventArgs args)
{
this.obj = obj;
this.args = args;
}
public EventArgs Args {
get {
return args;
}
}
public GLib.Object Target {
get {
return obj;
}
}
}
struct GClosure {
public long fields;
public IntPtr marshaler;
public IntPtr data;
public IntPtr notifiers;
}
internal delegate void ClosureInvokedHandler (object o, ClosureInvokedArgs args);
internal class SignalClosure : IDisposable {
IntPtr handle;
IntPtr raw_closure;
string name;
uint id = UInt32.MaxValue;
System.Type args_type;
Delegate custom_marshaler;
GCHandle gch;
static Hashtable closures = new Hashtable ();
public SignalClosure (IntPtr obj, string signal_name, System.Type args_type)
{
raw_closure = g_closure_new_simple (Marshal.SizeOf<GClosure> (), IntPtr.Zero);
g_closure_set_marshal (raw_closure, Marshaler);
g_closure_add_finalize_notifier (raw_closure, IntPtr.Zero, Notify);
closures [raw_closure] = this;
handle = obj;
name = signal_name;
this.args_type = args_type;
}
public SignalClosure (IntPtr obj, string signal_name, Delegate custom_marshaler, Signal signal)
{
gch = GCHandle.Alloc (signal);
raw_closure = g_cclosure_new (custom_marshaler, (IntPtr) gch, Notify);
closures [raw_closure] = this;
handle = obj;
name = signal_name;
this.custom_marshaler = custom_marshaler;
}
public event EventHandler Disposed;
public event ClosureInvokedHandler Invoked;
public void Connect (bool is_after)
{
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
id = g_signal_connect_closure (handle, native_name, raw_closure, is_after);
GLib.Marshaller.Free (native_name);
}
public void Disconnect ()
{
if (id != UInt32.MaxValue && g_signal_handler_is_connected (handle, id))
g_signal_handler_disconnect (handle, id);
}
public void Dispose ()
{
Disconnect ();
closures.Remove (raw_closure);
if (custom_marshaler != null)
gch.Free ();
custom_marshaler = null;
if (Disposed != null)
Disposed (this, EventArgs.Empty);
GC.SuppressFinalize (this);
}
public void Invoke (ClosureInvokedArgs args)
{
if (Invoked == null)
return;
Invoked (this, args);
}
static ClosureMarshal marshaler;
static ClosureMarshal Marshaler {
get {
if (marshaler == null)
marshaler = new ClosureMarshal (MarshalCallback);
return marshaler;
}
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void ClosureMarshal (IntPtr closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data);
static void MarshalCallback (IntPtr raw_closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
{
string message = String.Empty;
try {
SignalClosure closure = closures [raw_closure] as SignalClosure;
message = "Marshaling " + closure.name + " signal";
Value objval = (Value) Marshal.PtrToStructure (param_values, typeof (Value));
GLib.Object __obj = objval.Val as GLib.Object;
if (__obj == null)
return;
if (closure.args_type == typeof (EventArgs)) {
closure.Invoke (new ClosureInvokedArgs (__obj, EventArgs.Empty));
return;
}
SignalArgs args = Activator.CreateInstance (closure.args_type, new object [0]) as SignalArgs;
args.Args = new object [n_param_vals - 1];
GLib.Value[] vals = new GLib.Value [n_param_vals - 1];
for (int i = 1; i < n_param_vals; i++) {
IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf<Value> ());
vals [i - 1] = (Value) Marshal.PtrToStructure (ptr, typeof (Value));
args.Args [i - 1] = vals [i - 1].Val;
}
ClosureInvokedArgs ci_args = new ClosureInvokedArgs (__obj, args);
closure.Invoke (ci_args);
for (int i = 1; i < n_param_vals; i++) {
vals [i - 1].Update (args.Args [i - 1]);
IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf<Value> ());
Marshal.StructureToPtr (vals [i - 1], ptr, false);
}
if (return_val == IntPtr.Zero || args.RetVal == null)
return;
Value ret = (Value) Marshal.PtrToStructure (return_val, typeof (Value));
ret.Val = args.RetVal;
Marshal.StructureToPtr (ret, return_val, false);
} catch (Exception e) {
Console.WriteLine (message);
ExceptionManager.RaiseUnhandledException (e, false);
}
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void ClosureNotify (IntPtr data, IntPtr closure);
static void NotifyCallback (IntPtr data, IntPtr raw_closure)
{
SignalClosure closure = closures [raw_closure] as SignalClosure;
if (closure != null)
closure.Dispose ();
}
static ClosureNotify notify_handler;
static ClosureNotify Notify {
get {
if (notify_handler == null)
notify_handler = new ClosureNotify (NotifyCallback);
return notify_handler;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_cclosure_new(Delegate cb, IntPtr user_data, ClosureNotify notify);
static d_g_cclosure_new g_cclosure_new = FuncLoader.LoadFunction<d_g_cclosure_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_cclosure_new"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_closure_new_simple(int closure_size, IntPtr dummy);
static d_g_closure_new_simple g_closure_new_simple = FuncLoader.LoadFunction<d_g_closure_new_simple>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_closure_new_simple"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_closure_set_marshal(IntPtr closure, ClosureMarshal marshaler);
static d_g_closure_set_marshal g_closure_set_marshal = FuncLoader.LoadFunction<d_g_closure_set_marshal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_closure_set_marshal"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_closure_add_finalize_notifier(IntPtr closure, IntPtr dummy, ClosureNotify notify);
static d_g_closure_add_finalize_notifier g_closure_add_finalize_notifier = FuncLoader.LoadFunction<d_g_closure_add_finalize_notifier>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_closure_add_finalize_notifier"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_signal_connect_closure(IntPtr obj, IntPtr name, IntPtr closure, bool is_after);
static d_g_signal_connect_closure g_signal_connect_closure = FuncLoader.LoadFunction<d_g_signal_connect_closure>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_connect_closure"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_signal_handler_disconnect(IntPtr instance, uint handler);
static d_g_signal_handler_disconnect g_signal_handler_disconnect = FuncLoader.LoadFunction<d_g_signal_handler_disconnect>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_handler_disconnect"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_signal_handler_is_connected(IntPtr instance, uint handler);
static d_g_signal_handler_is_connected g_signal_handler_is_connected = FuncLoader.LoadFunction<d_g_signal_handler_is_connected>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_signal_handler_is_connected"));
}
}

View File

@@ -0,0 +1,408 @@
// GLib.Source.cs - Source class implementation
//
// Author: Duncan Mak <duncan@ximian.com>
//
// Copyright (c) 2002 Mike Kestner
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public delegate bool GSourceFunc ();
//
// Base class for IdleProxy and TimeoutProxy
//
internal class SourceProxy : IDisposable {
internal Delegate real_handler;
internal Delegate proxy_handler;
internal uint ID;
~SourceProxy ()
{
Dispose (false);
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
// Both branches remove our delegate from the
// managed list of handlers, but only
// Source.Remove will remove it from the
// unmanaged list also.
if (disposing)
Remove ();
else
Source.Remove (ID);
}
internal void Remove ()
{
real_handler = null;
proxy_handler = null;
}
}
public partial class Source : GLib.Opaque {
private Source () {}
public Source(IntPtr raw) : base(raw) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_source_new(IntPtr source_funcs, uint struct_size);
static d_g_source_new g_source_new = FuncLoader.LoadFunction<d_g_source_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_new"));
public Source (GLib.SourceFuncs source_funcs, uint struct_size)
{
IntPtr native_source_funcs = GLib.Marshaller.StructureToPtrAlloc (source_funcs);
Raw = g_source_new(native_source_funcs, struct_size);
source_funcs = GLib.SourceFuncs.New (native_source_funcs);
Marshal.FreeHGlobal (native_source_funcs);
}
class FinalizerInfo {
IntPtr handle;
public FinalizerInfo (IntPtr handle)
{
this.handle = handle;
}
public bool Handler ()
{
g_source_destroy (handle);
return false;
}
}
~Source ()
{
if (!Owned)
return;
FinalizerInfo info = new FinalizerInfo (Handle);
GLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_source_remove(uint tag);
static d_g_source_remove g_source_remove = FuncLoader.LoadFunction<d_g_source_remove>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_remove"));
public static bool Remove (uint tag)
{
return g_source_remove (tag);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_source_get_type();
static d_g_source_get_type g_source_get_type = FuncLoader.LoadFunction<d_g_source_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_type"));
public static GLib.GType GType {
get {
IntPtr raw_ret = g_source_get_type();
GLib.GType ret = new GLib.GType(raw_ret);
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_source_get_context(IntPtr raw);
static d_g_source_get_context g_source_get_context = FuncLoader.LoadFunction<d_g_source_get_context>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_context"));
public GLib.MainContext Context {
get {
IntPtr raw_ret = g_source_get_context(Handle);
GLib.MainContext ret = raw_ret == IntPtr.Zero ? null : new MainContext (raw_ret);
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_source_get_priority(IntPtr raw);
static d_g_source_get_priority g_source_get_priority = FuncLoader.LoadFunction<d_g_source_get_priority>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_priority"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_set_priority(IntPtr raw, int priority);
static d_g_source_set_priority g_source_set_priority = FuncLoader.LoadFunction<d_g_source_set_priority>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_set_priority"));
public int Priority {
get {
int raw_ret = g_source_get_priority(Handle);
int ret = raw_ret;
return ret;
}
set {
g_source_set_priority(Handle, value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_source_get_name(IntPtr raw);
static d_g_source_get_name g_source_get_name = FuncLoader.LoadFunction<d_g_source_get_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_name"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_set_name(IntPtr raw, IntPtr name);
static d_g_source_set_name g_source_set_name = FuncLoader.LoadFunction<d_g_source_set_name>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_set_name"));
public string Name {
get {
IntPtr raw_ret = g_source_get_name(Handle);
string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
return ret;
}
set {
IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
g_source_set_name(Handle, native_value);
GLib.Marshaller.Free (native_value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_add_child_source(IntPtr raw, IntPtr child_source);
static d_g_source_add_child_source g_source_add_child_source = FuncLoader.LoadFunction<d_g_source_add_child_source>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_add_child_source"));
public void AddChildSource(GLib.Source child_source) {
g_source_add_child_source(Handle, child_source == null ? IntPtr.Zero : child_source.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_add_poll(IntPtr raw, IntPtr fd);
static d_g_source_add_poll g_source_add_poll = FuncLoader.LoadFunction<d_g_source_add_poll>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_add_poll"));
public void AddPoll(GLib.PollFD fd) {
IntPtr native_fd = GLib.Marshaller.StructureToPtrAlloc (fd);
g_source_add_poll(Handle, native_fd);
fd = GLib.PollFD.New (native_fd);
Marshal.FreeHGlobal (native_fd);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_source_attach(IntPtr raw, IntPtr context);
static d_g_source_attach g_source_attach = FuncLoader.LoadFunction<d_g_source_attach>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_attach"));
public uint Attach(GLib.MainContext context) {
uint raw_ret = g_source_attach(Handle, context == null ? IntPtr.Zero : context.Handle);
uint ret = raw_ret;
return ret;
}
uint Attach() {
return Attach (null);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_source_get_can_recurse(IntPtr raw);
static d_g_source_get_can_recurse g_source_get_can_recurse = FuncLoader.LoadFunction<d_g_source_get_can_recurse>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_can_recurse"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_set_can_recurse(IntPtr raw, bool can_recurse);
static d_g_source_set_can_recurse g_source_set_can_recurse = FuncLoader.LoadFunction<d_g_source_set_can_recurse>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_set_can_recurse"));
public bool CanRecurse {
get {
bool raw_ret = g_source_get_can_recurse(Handle);
bool ret = raw_ret;
return ret;
}
set {
g_source_set_can_recurse(Handle, value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_get_current_time(IntPtr raw, IntPtr timeval);
static d_g_source_get_current_time g_source_get_current_time = FuncLoader.LoadFunction<d_g_source_get_current_time>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_current_time"));
[Obsolete]
public void GetCurrentTime(GLib.TimeVal timeval) {
IntPtr native_timeval = GLib.Marshaller.StructureToPtrAlloc (timeval);
g_source_get_current_time(Handle, native_timeval);
timeval = GLib.TimeVal.New (native_timeval);
Marshal.FreeHGlobal (native_timeval);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_source_get_id(IntPtr raw);
static d_g_source_get_id g_source_get_id = FuncLoader.LoadFunction<d_g_source_get_id>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_id"));
public uint Id {
get {
uint raw_ret = g_source_get_id(Handle);
uint ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate long d_g_source_get_ready_time(IntPtr raw);
static d_g_source_get_ready_time g_source_get_ready_time = FuncLoader.LoadFunction<d_g_source_get_ready_time>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_ready_time"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_set_ready_time(IntPtr raw, long ready_time);
static d_g_source_set_ready_time g_source_set_ready_time = FuncLoader.LoadFunction<d_g_source_set_ready_time>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_set_ready_time"));
public long ReadyTime {
get {
long raw_ret = g_source_get_ready_time(Handle);
long ret = raw_ret;
return ret;
}
set {
g_source_set_ready_time(Handle, value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate long d_g_source_get_time(IntPtr raw);
static d_g_source_get_time g_source_get_time = FuncLoader.LoadFunction<d_g_source_get_time>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_get_time"));
public long Time {
get {
long raw_ret = g_source_get_time(Handle);
long ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_source_is_destroyed(IntPtr raw);
static d_g_source_is_destroyed g_source_is_destroyed = FuncLoader.LoadFunction<d_g_source_is_destroyed>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_is_destroyed"));
public bool IsDestroyed {
get {
bool raw_ret = g_source_is_destroyed(Handle);
bool ret = raw_ret;
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_modify_unix_fd(IntPtr raw, IntPtr tag, int new_events);
static d_g_source_modify_unix_fd g_source_modify_unix_fd = FuncLoader.LoadFunction<d_g_source_modify_unix_fd>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_modify_unix_fd"));
public void ModifyUnixFd(IntPtr tag, GLib.IOCondition new_events) {
g_source_modify_unix_fd(Handle, tag, (int) new_events);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_source_query_unix_fd(IntPtr raw, IntPtr tag);
static d_g_source_query_unix_fd g_source_query_unix_fd = FuncLoader.LoadFunction<d_g_source_query_unix_fd>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_query_unix_fd"));
public GLib.IOCondition QueryUnixFd(IntPtr tag) {
int raw_ret = g_source_query_unix_fd(Handle, tag);
GLib.IOCondition ret = (GLib.IOCondition) raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_remove_child_source(IntPtr raw, IntPtr child_source);
static d_g_source_remove_child_source g_source_remove_child_source = FuncLoader.LoadFunction<d_g_source_remove_child_source>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_remove_child_source"));
public void RemoveChildSource(GLib.Source child_source) {
g_source_remove_child_source(Handle, child_source == null ? IntPtr.Zero : child_source.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_remove_poll(IntPtr raw, IntPtr fd);
static d_g_source_remove_poll g_source_remove_poll = FuncLoader.LoadFunction<d_g_source_remove_poll>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_remove_poll"));
public void RemovePoll(GLib.PollFD fd) {
IntPtr native_fd = GLib.Marshaller.StructureToPtrAlloc (fd);
g_source_remove_poll(Handle, native_fd);
fd = GLib.PollFD.New (native_fd);
Marshal.FreeHGlobal (native_fd);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_remove_unix_fd(IntPtr raw, IntPtr tag);
static d_g_source_remove_unix_fd g_source_remove_unix_fd = FuncLoader.LoadFunction<d_g_source_remove_unix_fd>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_remove_unix_fd"));
public void RemoveUnixFd(IntPtr tag) {
g_source_remove_unix_fd(Handle, tag);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_set_callback_indirect(IntPtr raw, IntPtr callback_data, IntPtr callback_funcs);
static d_g_source_set_callback_indirect g_source_set_callback_indirect = FuncLoader.LoadFunction<d_g_source_set_callback_indirect>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_set_callback_indirect"));
public void SetCallbackIndirect(IntPtr callback_data, GLib.SourceCallbackFuncs callback_funcs) {
IntPtr native_callback_funcs = GLib.Marshaller.StructureToPtrAlloc (callback_funcs);
g_source_set_callback_indirect(Handle, callback_data, native_callback_funcs);
callback_funcs = GLib.SourceCallbackFuncs.New (native_callback_funcs);
Marshal.FreeHGlobal (native_callback_funcs);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_set_funcs(IntPtr raw, IntPtr value);
static d_g_source_set_funcs g_source_set_funcs = FuncLoader.LoadFunction<d_g_source_set_funcs>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_set_funcs"));
public GLib.SourceFuncs Funcs {
set {
IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
g_source_set_funcs(Handle, native_value);
value = GLib.SourceFuncs.New (native_value);
Marshal.FreeHGlobal (native_value);
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_source_remove_by_funcs_user_data(IntPtr funcs, IntPtr user_data);
static d_g_source_remove_by_funcs_user_data g_source_remove_by_funcs_user_data = FuncLoader.LoadFunction<d_g_source_remove_by_funcs_user_data>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_remove_by_funcs_user_data"));
public static bool RemoveByFuncsUserData(GLib.SourceFuncs funcs, IntPtr user_data) {
IntPtr native_funcs = GLib.Marshaller.StructureToPtrAlloc (funcs);
bool raw_ret = g_source_remove_by_funcs_user_data(native_funcs, user_data);
bool ret = raw_ret;
funcs = GLib.SourceFuncs.New (native_funcs);
Marshal.FreeHGlobal (native_funcs);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_source_remove_by_user_data(IntPtr user_data);
static d_g_source_remove_by_user_data g_source_remove_by_user_data = FuncLoader.LoadFunction<d_g_source_remove_by_user_data>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_remove_by_user_data"));
public static bool RemoveByUserData(IntPtr user_data) {
bool raw_ret = g_source_remove_by_user_data(user_data);
bool ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_set_name_by_id(uint tag, IntPtr name);
static d_g_source_set_name_by_id g_source_set_name_by_id = FuncLoader.LoadFunction<d_g_source_set_name_by_id>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_set_name_by_id"));
public static void SetNameById(uint tag, string name) {
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
g_source_set_name_by_id(tag, native_name);
GLib.Marshaller.Free (native_name);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_source_ref(IntPtr raw);
static d_g_source_ref g_source_ref = FuncLoader.LoadFunction<d_g_source_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_ref"));
protected override void Ref (IntPtr raw)
{
if (!Owned) {
g_source_ref (raw);
Owned = true;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_unref(IntPtr raw);
static d_g_source_unref g_source_unref = FuncLoader.LoadFunction<d_g_source_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_unref"));
protected override void Unref (IntPtr raw)
{
if (Owned) {
g_source_unref (raw);
Owned = false;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_source_destroy(IntPtr raw);
static d_g_source_destroy g_source_destroy = FuncLoader.LoadFunction<d_g_source_destroy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_source_destroy"));
protected override void Free (IntPtr raw)
{
g_source_destroy (raw);
}
}
}

View File

@@ -0,0 +1,44 @@
// 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;
#region Autogenerated code
[StructLayout(LayoutKind.Sequential)]
public partial struct SourceCallbackFuncs : IEquatable<SourceCallbackFuncs> {
public static GLib.SourceCallbackFuncs Zero = new GLib.SourceCallbackFuncs ();
public static GLib.SourceCallbackFuncs New(IntPtr raw) {
if (raw == IntPtr.Zero)
return GLib.SourceCallbackFuncs.Zero;
return (GLib.SourceCallbackFuncs) Marshal.PtrToStructure (raw, typeof (GLib.SourceCallbackFuncs));
}
public bool Equals (SourceCallbackFuncs other)
{
return true;
}
public override bool Equals (object other)
{
return other is SourceCallbackFuncs && Equals ((SourceCallbackFuncs) other);
}
public override int GetHashCode ()
{
return this.GetType().FullName.GetHashCode();
}
private static GLib.GType GType {
get { return GLib.GType.Pointer; }
}
#endregion
}
}

View File

@@ -0,0 +1,10 @@
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.
namespace GLib {
using System;
public delegate void SourceDummyMarshal();
}

View File

@@ -0,0 +1,10 @@
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.
namespace GLib {
using System;
public delegate bool SourceFunc(IntPtr user_data);
}

View File

@@ -0,0 +1,46 @@
// 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;
#region Autogenerated code
[StructLayout(LayoutKind.Sequential)]
public partial struct SourceFuncs : IEquatable<SourceFuncs> {
internal GLibSharp.SourceFuncNative closure_callback;
internal GLibSharp.SourceDummyMarshalNative closure_marshal;
public static GLib.SourceFuncs Zero = new GLib.SourceFuncs ();
public static GLib.SourceFuncs New(IntPtr raw) {
if (raw == IntPtr.Zero)
return GLib.SourceFuncs.Zero;
return (GLib.SourceFuncs) Marshal.PtrToStructure (raw, typeof (GLib.SourceFuncs));
}
public bool Equals (SourceFuncs other)
{
return true && closure_callback.Equals (other.closure_callback) && closure_callback.Equals (other.closure_callback);
}
public override bool Equals (object other)
{
return other is SourceFuncs && Equals ((SourceFuncs) other);
}
public override int GetHashCode ()
{
return this.GetType().FullName.GetHashCode() ^ closure_marshal.GetHashCode () ^ closure_marshal.GetHashCode ();
}
private static GLib.GType GType {
get { return GLib.GType.Pointer; }
}
#endregion
}
}

View File

@@ -0,0 +1,262 @@
// glib/Spawn.cs : Spawn g_spawn API wrapper
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2007 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public enum SpawnError {
Fork,
Read,
Chdir,
Acces,
Perm,
TooBig,
NoExec,
NameTooLong,
NoEnt,
NoMem,
NotDir,
Loop,
TxtBusy,
IO,
NFile,
MFile,
Inval,
IsDir,
LibBad,
Failed,
}
[Flags]
public enum SpawnFlags {
LeaveDescriptorsOpen = 1 << 0,
DoNotReapChild = 1 << 1,
SearchPath = 1 << 2,
StdoutToDevNull = 1 << 3,
StderrToDevNull = 1 << 4,
ChildInheritsStdin = 1 << 5,
FileAndArgvZero = 1 << 6,
}
public delegate void SpawnChildSetupFunc ();
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void SpawnChildSetupFuncNative (IntPtr gch);
internal class SpawnChildSetupWrapper {
SpawnChildSetupFunc handler;
public SpawnChildSetupWrapper (SpawnChildSetupFunc handler)
{
if (handler == null)
return;
this.handler = handler;
Data = (IntPtr) GCHandle.Alloc (this);
NativeCallback = new SpawnChildSetupFuncNative (InvokeHandler);
}
public IntPtr Data;
public SpawnChildSetupFuncNative NativeCallback;
static void InvokeHandler (IntPtr data)
{
if (data == IntPtr.Zero)
return;
GCHandle gch = (GCHandle) data;
(gch.Target as SpawnChildSetupWrapper).handler ();
gch.Free ();
}
}
public class Process {
public const int IgnorePipe = Int32.MaxValue;
public const int RequestPipe = 0;
long pid;
private Process (int pid)
{
this.pid = pid;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_spawn_close_pid(int pid);
static d_g_spawn_close_pid g_spawn_close_pid = FuncLoader.LoadFunction<d_g_spawn_close_pid>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_spawn_close_pid"));
public void Close ()
{
g_spawn_close_pid ((int) pid);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_async(IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out int pid, out IntPtr error);
static d_g_spawn_async g_spawn_async = FuncLoader.LoadFunction<d_g_spawn_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_spawn_async"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_async_utf8(IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out int pid, out IntPtr error);
static d_g_spawn_async_utf8 g_spawn_async_utf8 = FuncLoader.LoadFunction<d_g_spawn_async_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_spawn_async_utf8"));
public static bool SpawnAsync (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out Process child_process)
{
int pid;
IntPtr error;
IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory);
IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv);
IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp);
SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup);
bool result;
if (Global.IsWindowsPlatform)
result = g_spawn_async_utf8 (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out pid, out error);
else
result = g_spawn_async (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out pid, out error);
child_process = new Process (pid);
Marshaller.Free (native_dir);
Marshaller.Free (native_argv);
Marshaller.Free (native_envp);
if (error != IntPtr.Zero) throw new GLib.GException (error);
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_async_with_pipes(IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out int pid, IntPtr stdin, IntPtr stdout, IntPtr stderr, out IntPtr error);
static d_g_spawn_async_with_pipes g_spawn_async_with_pipes = FuncLoader.LoadFunction<d_g_spawn_async_with_pipes>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_spawn_async_with_pipes"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_async_with_pipes_utf8(IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out int pid, IntPtr stdin, IntPtr stdout, IntPtr stderr, out IntPtr error);
static d_g_spawn_async_with_pipes_utf8 g_spawn_async_with_pipes_utf8 = FuncLoader.LoadFunction<d_g_spawn_async_with_pipes_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_spawn_async_with_pipes_utf8"));
public static bool SpawnAsyncWithPipes (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out Process child_process, ref int stdin, ref int stdout, ref int stderr)
{
int pid;
IntPtr error;
IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory);
IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv);
IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp);
SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup);
IntPtr in_ptr = stdin == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4);
IntPtr out_ptr = stdout == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4);
IntPtr err_ptr = stderr == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4);
bool result;
if (Global.IsWindowsPlatform)
result = g_spawn_async_with_pipes_utf8 (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out pid, in_ptr, out_ptr, err_ptr, out error);
else
result = g_spawn_async_with_pipes (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out pid, in_ptr, out_ptr, err_ptr, out error);
child_process = new Process (pid);
if (in_ptr != IntPtr.Zero) {
stdin = Marshal.ReadInt32 (in_ptr);
Marshal.FreeHGlobal (in_ptr);
}
if (out_ptr != IntPtr.Zero) {
stdout = Marshal.ReadInt32 (out_ptr);
Marshal.FreeHGlobal (out_ptr);
}
if (err_ptr != IntPtr.Zero) {
stderr = Marshal.ReadInt32 (err_ptr);
Marshal.FreeHGlobal (err_ptr);
}
Marshaller.Free (native_dir);
Marshaller.Free (native_argv);
Marshaller.Free (native_envp);
if (error != IntPtr.Zero) throw new GLib.GException (error);
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_sync(IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out IntPtr stdout, out IntPtr stderr, out int exit_status, out IntPtr error);
static d_g_spawn_sync g_spawn_sync = FuncLoader.LoadFunction<d_g_spawn_sync>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_spawn_sync"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_sync_utf8(IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out IntPtr stdout, out IntPtr stderr, out int exit_status, out IntPtr error);
static d_g_spawn_sync_utf8 g_spawn_sync_utf8 = FuncLoader.LoadFunction<d_g_spawn_sync_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_spawn_sync_utf8"));
public static bool SpawnSync (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out string stdout, out string stderr, out int exit_status)
{
IntPtr native_stdout, native_stderr, error;
IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory);
IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv);
IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp);
SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup);
bool result;
if (Global.IsWindowsPlatform)
result = g_spawn_sync (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out native_stdout, out native_stderr, out exit_status, out error);
else
result = g_spawn_sync (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out native_stdout, out native_stderr, out exit_status, out error);
Marshaller.Free (native_dir);
Marshaller.Free (native_argv);
Marshaller.Free (native_envp);
stdout = Marshaller.PtrToStringGFree (native_stdout);
stderr = Marshaller.PtrToStringGFree (native_stderr);
if (error != IntPtr.Zero) throw new GLib.GException (error);
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_command_line_async(IntPtr cmdline, out IntPtr error);
static d_g_spawn_command_line_async g_spawn_command_line_async = FuncLoader.LoadFunction<d_g_spawn_command_line_async>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_spawn_command_line_async"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_command_line_async_utf8(IntPtr cmdline, out IntPtr error);
static d_g_spawn_command_line_async_utf8 g_spawn_command_line_async_utf8 = FuncLoader.LoadFunction<d_g_spawn_command_line_async_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_spawn_command_line_async_utf8"));
public static bool SpawnCommandLineAsync (string command_line)
{
IntPtr error;
IntPtr native_cmd = Marshaller.StringToPtrGStrdup (command_line);
bool result;
if (Global.IsWindowsPlatform)
result = g_spawn_command_line_async_utf8 (native_cmd, out error);
else
result = g_spawn_command_line_async (native_cmd, out error);
Marshaller.Free (native_cmd);
if (error != IntPtr.Zero) throw new GLib.GException (error);
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_command_line_sync(IntPtr cmdline, out IntPtr stdout, out IntPtr stderr, out int exit_status, out IntPtr error);
static d_g_spawn_command_line_sync g_spawn_command_line_sync = FuncLoader.LoadFunction<d_g_spawn_command_line_sync>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_spawn_command_line_sync"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_spawn_command_line_sync_utf8(IntPtr cmdline, out IntPtr stdout, out IntPtr stderr, out int exit_status, out IntPtr error);
static d_g_spawn_command_line_sync_utf8 g_spawn_command_line_sync_utf8 = FuncLoader.LoadFunction<d_g_spawn_command_line_sync_utf8>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_spawn_command_line_sync_utf8"));
public static bool SpawnCommandLineSync (string command_line, out string stdout, out string stderr, out int exit_status)
{
IntPtr error, native_stdout, native_stderr;
IntPtr native_cmd = Marshaller.StringToPtrGStrdup (command_line);
bool result;
if (Global.IsWindowsPlatform)
result = g_spawn_command_line_sync_utf8 (native_cmd, out native_stdout, out native_stderr, out exit_status, out error);
else
result = g_spawn_command_line_sync (native_cmd, out native_stdout, out native_stderr, out exit_status, out error);
Marshaller.Free (native_cmd);
stdout = Marshaller.PtrToStringGFree (native_stdout);
stderr = Marshaller.PtrToStringGFree (native_stderr);
if (error != IntPtr.Zero) throw new GLib.GException (error);
return result;
}
}
}

View File

@@ -0,0 +1,44 @@
// Thread.cs - thread awareness
//
// Author: Alp Toker <alp@atoker.com>
//
// Copyright (c) 2002 Alp Toker
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib
{
using System;
using System.Runtime.InteropServices;
public class Thread
{
private Thread () {}
[Obsolete ("This is no longer needed, GLib automatically initializes threads")]
public static void Init ()
{
// GLib automatically inits threads in 2.31 and above
// http://developer.gnome.org/glib/unstable/glib-Deprecated-Thread-APIs.html#g-thread-init
}
public static bool Supported
{
get { return true; }
}
}
}

View File

@@ -0,0 +1,106 @@
// 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;
#region Autogenerated code
[StructLayout(LayoutKind.Sequential)]
public partial struct TimeVal : IEquatable<TimeVal> {
private IntPtr tv_sec;
public long TvSec {
get {
return (long) tv_sec;
}
set {
tv_sec = new IntPtr (value);
}
}
private IntPtr tv_usec;
public long TvUsec {
get {
return (long) tv_usec;
}
set {
tv_usec = new IntPtr (value);
}
}
public static GLib.TimeVal Zero = new GLib.TimeVal ();
public static GLib.TimeVal New(IntPtr raw) {
if (raw == IntPtr.Zero)
return GLib.TimeVal.Zero;
return (GLib.TimeVal) Marshal.PtrToStructure (raw, typeof (GLib.TimeVal));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_time_val_add(IntPtr raw, IntPtr microseconds);
static d_g_time_val_add g_time_val_add = FuncLoader.LoadFunction<d_g_time_val_add>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_val_add"));
public void Add(long microseconds) {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<TimeVal> ());
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
g_time_val_add(this_as_native, new IntPtr (microseconds));
ReadNative (this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_time_val_to_iso8601(IntPtr raw);
static d_g_time_val_to_iso8601 g_time_val_to_iso8601 = FuncLoader.LoadFunction<d_g_time_val_to_iso8601>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_val_to_iso8601"));
public string ToIso8601() {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf<TimeVal> ());
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
IntPtr raw_ret = g_time_val_to_iso8601(this_as_native);
string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
ReadNative (this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_time_val_from_iso8601(IntPtr iso_date, IntPtr time_);
static d_g_time_val_from_iso8601 g_time_val_from_iso8601 = FuncLoader.LoadFunction<d_g_time_val_from_iso8601>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_val_from_iso8601"));
public static bool FromIso8601(string iso_date, out GLib.TimeVal time_) {
IntPtr native_iso_date = GLib.Marshaller.StringToPtrGStrdup (iso_date);
IntPtr native_time_ = Marshal.AllocHGlobal (Marshal.SizeOf<GLib.TimeVal> ());
bool raw_ret = g_time_val_from_iso8601(native_iso_date, native_time_);
bool ret = raw_ret;
GLib.Marshaller.Free (native_iso_date);
time_ = GLib.TimeVal.New (native_time_);
Marshal.FreeHGlobal (native_time_);
return ret;
}
static void ReadNative (IntPtr native, ref GLib.TimeVal target)
{
target = New (native);
}
public bool Equals (TimeVal other)
{
return true && TvSec.Equals (other.TvSec) && TvUsec.Equals (other.TvUsec);
}
public override bool Equals (object other)
{
return other is TimeVal && Equals ((TimeVal) other);
}
public override int GetHashCode ()
{
return this.GetType().FullName.GetHashCode() ^ TvSec.GetHashCode () ^ TvUsec.GetHashCode ();
}
private static GLib.GType GType {
get { return GLib.GType.Pointer; }
}
#endregion
}
}

View File

@@ -0,0 +1,147 @@
// 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;
#region Autogenerated code
public partial class TimeZone : GLib.Opaque {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_time_zone_get_type();
static d_g_time_zone_get_type g_time_zone_get_type = FuncLoader.LoadFunction<d_g_time_zone_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_get_type"));
public static GLib.GType GType {
get {
IntPtr raw_ret = g_time_zone_get_type();
GLib.GType ret = new GLib.GType(raw_ret);
return ret;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_time_zone_adjust_time(IntPtr raw, int type, long time_);
static d_g_time_zone_adjust_time g_time_zone_adjust_time = FuncLoader.LoadFunction<d_g_time_zone_adjust_time>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_adjust_time"));
public int AdjustTime(int type, long time_) {
int raw_ret = g_time_zone_adjust_time(Handle, type, time_);
int ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_time_zone_find_interval(IntPtr raw, int type, long time_);
static d_g_time_zone_find_interval g_time_zone_find_interval = FuncLoader.LoadFunction<d_g_time_zone_find_interval>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_find_interval"));
public int FindInterval(int type, long time_) {
int raw_ret = g_time_zone_find_interval(Handle, type, time_);
int ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_time_zone_get_abbreviation(IntPtr raw, int interval);
static d_g_time_zone_get_abbreviation g_time_zone_get_abbreviation = FuncLoader.LoadFunction<d_g_time_zone_get_abbreviation>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_get_abbreviation"));
public string GetAbbreviation(int interval) {
IntPtr raw_ret = g_time_zone_get_abbreviation(Handle, interval);
string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_time_zone_get_offset(IntPtr raw, int interval);
static d_g_time_zone_get_offset g_time_zone_get_offset = FuncLoader.LoadFunction<d_g_time_zone_get_offset>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_get_offset"));
public int GetOffset(int interval) {
int raw_ret = g_time_zone_get_offset(Handle, interval);
int ret = raw_ret;
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_time_zone_is_dst(IntPtr raw, int interval);
static d_g_time_zone_is_dst g_time_zone_is_dst = FuncLoader.LoadFunction<d_g_time_zone_is_dst>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_is_dst"));
public bool IsDst(int interval) {
bool raw_ret = g_time_zone_is_dst(Handle, interval);
bool ret = raw_ret;
return ret;
}
public TimeZone(IntPtr raw) : base(raw) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_time_zone_new(IntPtr identifier);
static d_g_time_zone_new g_time_zone_new = FuncLoader.LoadFunction<d_g_time_zone_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_new"));
public TimeZone (string identifier)
{
IntPtr native_identifier = GLib.Marshaller.StringToPtrGStrdup (identifier);
Raw = g_time_zone_new(native_identifier);
GLib.Marshaller.Free (native_identifier);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_time_zone_new_local();
static d_g_time_zone_new_local g_time_zone_new_local = FuncLoader.LoadFunction<d_g_time_zone_new_local>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_new_local"));
public TimeZone ()
{
Raw = g_time_zone_new_local();
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_time_zone_new_utc();
static d_g_time_zone_new_utc g_time_zone_new_utc = FuncLoader.LoadFunction<d_g_time_zone_new_utc>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_new_utc"));
public static TimeZone NewUtc()
{
TimeZone result = new TimeZone (g_time_zone_new_utc());
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_time_zone_ref(IntPtr raw);
static d_g_time_zone_ref g_time_zone_ref = FuncLoader.LoadFunction<d_g_time_zone_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_ref"));
protected override void Ref (IntPtr raw)
{
if (!Owned) {
g_time_zone_ref (raw);
Owned = true;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_time_zone_unref(IntPtr raw);
static d_g_time_zone_unref g_time_zone_unref = FuncLoader.LoadFunction<d_g_time_zone_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_time_zone_unref"));
protected override void Unref (IntPtr raw)
{
if (Owned) {
g_time_zone_unref (raw);
Owned = false;
}
}
class FinalizerInfo {
IntPtr handle;
public FinalizerInfo (IntPtr handle)
{
this.handle = handle;
}
public bool Handler ()
{
g_time_zone_unref (handle);
return false;
}
}
~TimeZone ()
{
if (!Owned)
return;
FinalizerInfo info = new FinalizerInfo (Handle);
GLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));
}
#endregion
}
}

View File

@@ -0,0 +1,119 @@
// GLib.Timeout.cs - Timeout class implementation
//
// Author(s):
// Mike Kestner <mkestner@speakeasy.net>
// Stephane Delcroix <stephane@delcroix.org>
//
// Copyright (c) 2002 Mike Kestner
// Copyright (c) 2009 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public delegate bool TimeoutHandler ();
public class Timeout {
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate bool TimeoutHandlerInternal ();
internal class TimeoutProxy : SourceProxy {
public TimeoutProxy (TimeoutHandler real)
{
real_handler = real;
proxy_handler = new TimeoutHandlerInternal (Handler);
}
public bool Handler ()
{
try {
TimeoutHandler timeout_handler = (TimeoutHandler) real_handler;
bool cont = timeout_handler ();
return cont;
} catch (Exception e) {
ExceptionManager.RaiseUnhandledException (e, false);
}
return false;
}
}
private Timeout () {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_timeout_add_full(int priority, uint interval, TimeoutHandlerInternal d, IntPtr data, DestroyNotify notify);
static d_g_timeout_add_full g_timeout_add_full = FuncLoader.LoadFunction<d_g_timeout_add_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_timeout_add_full"));
public static uint Add (uint interval, TimeoutHandler hndlr, int priority)
{
TimeoutProxy p = new TimeoutProxy (hndlr);
lock (p)
{
var gch = GCHandle.Alloc(p);
var userData = GCHandle.ToIntPtr(gch);
p.ID = g_timeout_add_full (priority, interval, (TimeoutHandlerInternal) p.proxy_handler, userData, DestroyHelper.SourceProxyNotifyHandler);
}
return p.ID;
}
public static uint Add (uint interval, TimeoutHandler hndlr, Priority priority)
{
return Add (interval, hndlr, (int)priority);
}
public static uint Add (uint interval, TimeoutHandler hndlr)
{
return Add (interval, hndlr, (int)Priority.Default);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_timeout_add_seconds_full(int priority, uint interval, TimeoutHandlerInternal d, IntPtr data, DestroyNotify notify);
static d_g_timeout_add_seconds_full g_timeout_add_seconds_full = FuncLoader.LoadFunction<d_g_timeout_add_seconds_full>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_timeout_add_seconds_full"));
public static uint AddSeconds (uint interval, TimeoutHandler hndlr, int priority)
{
TimeoutProxy p = new TimeoutProxy (hndlr);
lock (p)
{
var gch = GCHandle.Alloc(p);
var userData = GCHandle.ToIntPtr(gch);
p.ID = g_timeout_add_seconds_full (priority, interval, (TimeoutHandlerInternal) p.proxy_handler, userData, DestroyHelper.SourceProxyNotifyHandler);
}
return p.ID;
}
public static uint AddSeconds (uint interval, TimeoutHandler hndlr, Priority priority)
{
return AddSeconds (interval, hndlr, (int)priority);
}
public static uint AddSeconds (uint interval, TimeoutHandler hndlr)
{
return AddSeconds (interval, hndlr, (int)Priority.Default);
}
public static void Remove (uint id)
{
Source.Remove (id);
}
}
}

View File

@@ -0,0 +1,208 @@
// GLib.ToggleRef.cs - GLib ToggleRef class implementation
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright <c> 2007, 2011 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace GLib {
internal class ToggleRef : IDisposable {
bool hardened;
IntPtr handle;
object reference;
GCHandle gch;
public ToggleRef (GLib.Object target)
{
handle = target.Handle;
gch = GCHandle.Alloc (this);
reference = target;
g_object_add_toggle_ref (target.Handle, ToggleNotifyCallback, (IntPtr) gch);
g_object_unref (target.Handle);
}
public IntPtr Handle {
get { return handle; }
}
public GLib.Object Target {
get {
if (reference == null)
return null;
else if (reference is GLib.Object)
return reference as GLib.Object;
WeakReference weak = (WeakReference)reference;
return weak.Target as GLib.Object;
}
}
public void Dispose ()
{
lock (PendingDestroys) {
PendingDestroys.Remove (this);
}
Free ();
}
void Free ()
{
if (hardened)
g_object_unref (handle);
else
g_object_remove_toggle_ref (handle, ToggleNotifyCallback, (IntPtr) gch);
reference = null;
QueueGCHandleFree ();
handle = IntPtr.Zero;
}
internal void Harden ()
{
// Added for the benefit of GnomeProgram. It releases a final ref in
// an atexit handler which causes toggle ref notifications to occur after
// our delegates are gone, so we need a mechanism to override the
// notifications. This method effectively leaks all objects which invoke it,
// but since it is only used by Gnome.Program, which is a singleton object
// with program duration persistence, who cares.
g_object_ref (handle);
g_object_remove_toggle_ref (handle, ToggleNotifyCallback, (IntPtr) gch);
if (reference is WeakReference)
reference = (reference as WeakReference).Target;
hardened = true;
}
void Toggle (bool is_last_ref)
{
if (is_last_ref && reference is GLib.Object)
reference = new WeakReference (reference);
else if (!is_last_ref && reference is WeakReference) {
WeakReference weak = reference as WeakReference;
if (weak.IsAlive)
reference = weak.Target;
}
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void ToggleNotifyHandler (IntPtr data, IntPtr handle, bool is_last_ref);
static void RefToggled (IntPtr data, IntPtr handle, bool is_last_ref)
{
try {
GCHandle gch = (GCHandle) data;
ToggleRef tref = (ToggleRef)gch.Target;
tref?.Toggle (is_last_ref);
} catch (Exception e) {
ExceptionManager.RaiseUnhandledException (e, false);
}
}
static ToggleNotifyHandler toggle_notify_callback;
static ToggleNotifyHandler ToggleNotifyCallback {
get {
if (toggle_notify_callback == null)
toggle_notify_callback = new ToggleNotifyHandler (RefToggled);
return toggle_notify_callback;
}
}
static List<GCHandle> PendingGCHandleFrees = new List<GCHandle> ();
static bool gc_idle_queued;
public void QueueGCHandleFree ()
{
lock (PendingGCHandleFrees) {
PendingGCHandleFrees.Add (gch);
if (!gc_idle_queued){
Timeout.Add (50, new TimeoutHandler (PerformGCHandleFrees));
gc_idle_queued = true;
}
}
}
static bool PerformGCHandleFrees ()
{
GCHandle[] handles;
lock (PendingGCHandleFrees){
handles = new GCHandle [PendingGCHandleFrees.Count];
PendingGCHandleFrees.CopyTo (handles, 0);
PendingGCHandleFrees.Clear ();
gc_idle_queued = false;
}
foreach (GCHandle r in handles)
r.Free ();
return false;
}
static List<ToggleRef> PendingDestroys = new List<ToggleRef> ();
static bool idle_queued;
public void QueueUnref ()
{
lock (PendingDestroys) {
PendingDestroys.Add (this);
if (!idle_queued){
Timeout.Add (50, new TimeoutHandler (PerformQueuedUnrefs));
idle_queued = true;
}
}
}
static bool PerformQueuedUnrefs ()
{
ToggleRef[] references;
lock (PendingDestroys){
references = new ToggleRef [PendingDestroys.Count];
PendingDestroys.CopyTo (references, 0);
PendingDestroys.Clear ();
idle_queued = false;
}
foreach (ToggleRef r in references)
r.Free ();
return false;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_object_add_toggle_ref(IntPtr raw, ToggleNotifyHandler notify_cb, IntPtr data);
static d_g_object_add_toggle_ref g_object_add_toggle_ref = FuncLoader.LoadFunction<d_g_object_add_toggle_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_add_toggle_ref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_object_remove_toggle_ref(IntPtr raw, ToggleNotifyHandler notify_cb, IntPtr data);
static d_g_object_remove_toggle_ref g_object_remove_toggle_ref = FuncLoader.LoadFunction<d_g_object_remove_toggle_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_remove_toggle_ref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_object_ref(IntPtr raw);
static d_g_object_ref g_object_ref = FuncLoader.LoadFunction<d_g_object_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_ref"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_object_unref(IntPtr raw);
static d_g_object_unref g_object_unref = FuncLoader.LoadFunction<d_g_object_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_unref"));
}
}

View File

@@ -0,0 +1,48 @@
// GLib.TypeFundamentals.cs : Standard Types enumeration
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// Copyright (c) 2001 Mike Kestner
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
public enum TypeFundamentals {
TypeInvalid = 0 << 2,
TypeNone = 1 << 2,
TypeInterface = 2 << 2,
TypeChar = 3 << 2,
TypeUChar = 4 << 2,
TypeBoolean = 5 << 2,
TypeInt = 6 << 2,
TypeUInt = 7 << 2,
TypeLong = 8 << 2,
TypeULong = 9 << 2,
TypeInt64 = 10 << 2,
TypeUInt64 = 11 << 2,
TypeEnum = 12 << 2,
TypeFlags = 13 << 2,
TypeFloat = 14 << 2,
TypeDouble = 15 << 2,
TypeString = 16 << 2,
TypePointer = 17 << 2,
TypeBoxed = 18 << 2,
TypeParam = 19 << 2,
TypeObject = 20 << 2,
TypeVariant = 21 << 2
}
}

View File

@@ -0,0 +1,48 @@
// TypeInitializerAttribute.cs
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2007 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
[AttributeUsage (AttributeTargets.Class)]
public sealed class TypeInitializerAttribute : Attribute
{
string method_name;
Type type;
public TypeInitializerAttribute (Type type, string method_name)
{
this.type = type;
this.method_name = method_name;
}
public string MethodName {
get { return method_name; }
set { method_name = value; }
}
public Type Type {
get { return type; }
set { type = value; }
}
}
}

View File

@@ -0,0 +1,41 @@
// TypeNameAttribute.cs
//
// Copyright (c) 2015 Martin Kupec
// Copyright (c) 2015 Ales Kurecka
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
[AttributeUsage (AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class TypeNameAttribute : Attribute {
private readonly string name;
public TypeNameAttribute (string name)
{
this.name = name;
}
public string Name
{
get {
return name;
}
}
}
}

View File

@@ -0,0 +1,776 @@
// GLib.Value.cs - GLib Value class implementation
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// Copyright (c) 2001 Mike Kestner
// Copyright (c) 2003-2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Reflection;
using System.Runtime.InteropServices;
[StructLayout (LayoutKind.Sequential)]
public struct Value : IDisposable {
IntPtr type;
#pragma warning disable 0414
long pad1;
long pad2;
#pragma warning restore 0414
public static Value Empty;
public Value (GLib.GType gtype)
{
type = IntPtr.Zero;
pad1 = pad2 = 0;
g_value_init (ref this, gtype.Val);
}
public Value (object obj)
{
type = IntPtr.Zero;
pad1 = pad2 = 0;
GType gtype = (GType) obj.GetType ();
g_value_init (ref this, gtype.Val);
Val = obj;
}
public Value (bool val) : this (GType.Boolean)
{
g_value_set_boolean (ref this, val);
}
public Value (byte val) : this (GType.UChar)
{
g_value_set_uchar (ref this, val);
}
public Value (sbyte val) : this (GType.Char)
{
g_value_set_char (ref this, val);
}
public Value (int val) : this (GType.Int)
{
g_value_set_int (ref this, val);
}
public Value (uint val) : this (GType.UInt)
{
g_value_set_uint (ref this, val);
}
public Value (ushort val) : this (GType.UInt)
{
g_value_set_uint (ref this, val);
}
public Value (long val) : this (GType.Int64)
{
g_value_set_int64 (ref this, val);
}
public Value (ulong val) : this (GType.UInt64)
{
g_value_set_uint64 (ref this, val);
}
public Value (float val) : this (GType.Float)
{
g_value_set_float (ref this, val);
}
public Value (double val) : this (GType.Double)
{
g_value_set_double (ref this, val);
}
public Value (string val) : this (GType.String)
{
IntPtr native_val = GLib.Marshaller.StringToPtrGStrdup (val);
g_value_set_string (ref this, native_val);
GLib.Marshaller.Free (native_val);
}
public Value (ValueArray val) : this (ValueArray.GType)
{
g_value_set_boxed (ref this, val.Handle);
}
public Value (IntPtr val) : this (GType.Pointer)
{
g_value_set_pointer (ref this, val);
}
public Value (Variant variant) : this (GType.Variant)
{
g_value_set_variant (ref this, variant == null ? IntPtr.Zero : variant.Handle);
}
public Value (Opaque val, string type_name)
{
type = IntPtr.Zero;
pad1 = pad2 = 0;
g_value_init (ref this, GType.FromName (type_name).Val);
g_value_set_boxed (ref this, val.Handle);
}
public Value (GLib.Object val) : this (val == null ? GType.Object : val.NativeType)
{
g_value_set_object (ref this, val == null ? IntPtr.Zero : val.Handle);
}
public Value (GLib.GInterfaceAdapter val) : this (val == null ? GType.Object : val.GInterfaceGType)
{
g_value_set_object (ref this, val == null ? IntPtr.Zero : val.Handle);
}
public Value (GLib.Object obj, string prop_name)
{
type = IntPtr.Zero;
pad1 = pad2 = 0;
InitForProperty (obj, prop_name);
}
[Obsolete]
public Value (IntPtr obj, string prop_name, Opaque val)
{
type = IntPtr.Zero;
pad1 = pad2 = 0;
InitForProperty (GLib.Object.GetObject (obj), prop_name);
g_value_set_boxed (ref this, val.Handle);
}
public Value (string[] val) : this (new GLib.GType (g_strv_get_type ()))
{
if (val == null) {
g_value_set_boxed (ref this, IntPtr.Zero);
return;
}
IntPtr native_array = Marshal.AllocHGlobal ((val.Length + 1) * IntPtr.Size);
for (int i = 0; i < val.Length; i++)
Marshal.WriteIntPtr (native_array, i * IntPtr.Size, GLib.Marshaller.StringToPtrGStrdup (val[i]));
Marshal.WriteIntPtr (native_array, val.Length * IntPtr.Size, IntPtr.Zero);
g_value_set_boxed (ref this, native_array);
for (int i = 0; i < val.Length; i++)
GLib.Marshaller.Free (Marshal.ReadIntPtr (native_array, i * IntPtr.Size));
Marshal.FreeHGlobal (native_array);
}
public void Dispose ()
{
g_value_unset (ref this);
}
public void Init (GLib.GType gtype)
{
g_value_init (ref this, gtype.Val);
}
public static explicit operator bool (Value val)
{
return g_value_get_boolean (ref val);
}
public static explicit operator byte (Value val)
{
return g_value_get_uchar (ref val);
}
public static explicit operator sbyte (Value val)
{
return g_value_get_char (ref val);
}
public static explicit operator int (Value val)
{
return g_value_get_int (ref val);
}
public static explicit operator uint (Value val)
{
return g_value_get_uint (ref val);
}
public static explicit operator ushort (Value val)
{
return (ushort) g_value_get_uint (ref val);
}
public static explicit operator long (Value val)
{
if (val.type == GType.Long.Val)
return val.GetLongForPlatform ();
else
return g_value_get_int64 (ref val);
}
public static explicit operator ulong (Value val)
{
if (val.type == GType.ULong.Val)
return val.GetULongForPlatform ();
else
return g_value_get_uint64 (ref val);
}
public static explicit operator Enum (Value val)
{
if (val.HoldsFlags)
return (Enum)Enum.ToObject (GType.LookupType (val.type), g_value_get_flags (ref val));
else
return (Enum)Enum.ToObject (GType.LookupType (val.type), g_value_get_enum (ref val));
}
public static explicit operator float (Value val)
{
return g_value_get_float (ref val);
}
public static explicit operator double (Value val)
{
return g_value_get_double (ref val);
}
public static explicit operator GLib.GType (Value val)
{
return g_value_get_gtype (ref val);
}
public static explicit operator string (Value val)
{
IntPtr str = g_value_get_string (ref val);
return str == IntPtr.Zero ? null : GLib.Marshaller.Utf8PtrToString (str);
}
public static explicit operator ValueArray (Value val)
{
return new ValueArray (g_value_get_boxed (ref val));
}
public static explicit operator IntPtr (Value val)
{
return g_value_get_pointer (ref val);
}
public static explicit operator GLib.Opaque (Value val)
{
return GLib.Opaque.GetOpaque (g_value_get_boxed (ref val), (Type) new GType (val.type), false);
}
public static explicit operator GLib.Variant (Value val)
{
IntPtr native_variant = g_value_get_variant (ref val);
return native_variant == IntPtr.Zero ? null : new Variant (native_variant);
}
public static explicit operator GLib.VariantType (Value val)
{
return new VariantType (g_value_get_boxed (ref val));
}
public static explicit operator GLib.Object (Value val)
{
return GLib.Object.GetObject (g_value_get_object (ref val), false);
}
public static explicit operator string[] (Value val)
{
IntPtr native_array = g_value_get_boxed (ref val);
if (native_array == IntPtr.Zero)
return null;
int count = 0;
while (Marshal.ReadIntPtr (native_array, count * IntPtr.Size) != IntPtr.Zero)
count++;
string[] strings = new string[count];
for (int i = 0; i < count; i++)
strings[i] = GLib.Marshaller.Utf8PtrToString (Marshal.ReadIntPtr (native_array, i * IntPtr.Size));
return strings;
}
object ToRegisteredType () {
Type t = GLib.GType.LookupType (type);
ConstructorInfo ci = null;
try {
while (ci == null && t != null) {
if (!t.IsAbstract)
ci = t.GetConstructor (new Type[] { typeof (GLib.Value) });
if (ci == null)
t = t.BaseType;
}
} catch (Exception) {
ci = null;
}
if (ci == null)
throw new Exception ("Unknown type " + new GType (type).ToString ());
return ci.Invoke (new object[] {this});
}
void FromRegisteredType (object val) {
Type t = GLib.GType.LookupType (type);
MethodInfo mi = null;
try {
while (mi == null && t != null) {
mi = t.GetMethod ("SetGValue", new Type[] { Type.GetType ("GLib.Value&") });
if (mi != null && (mi.IsAbstract || mi.ReturnType != typeof (void)))
mi = null;
if (mi == null)
t = t.BaseType;
}
} catch (Exception) {
mi = null;
}
if (mi == null)
throw new Exception ("Unknown type " + new GType (type).ToString ());
object[] parameters = new object[] { this };
mi.Invoke (val, parameters);
this = (GLib.Value) parameters[0];
}
long GetLongForPlatform ()
{
switch (Environment.OSVersion.Platform) {
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
return (long) g_value_get_long_as_int (ref this);
default:
return g_value_get_long (ref this).ToInt64 ();
}
}
ulong GetULongForPlatform ()
{
switch (Environment.OSVersion.Platform) {
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
return (ulong) g_value_get_ulong_as_uint (ref this);
default:
return g_value_get_ulong (ref this).ToUInt64 ();
}
}
void SetLongForPlatform (long val)
{
switch (Environment.OSVersion.Platform) {
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
g_value_set_long2 (ref this, (int) val);
break;
default:
g_value_set_long (ref this, new IntPtr (val));
break;
}
}
void SetULongForPlatform (ulong val)
{
switch (Environment.OSVersion.Platform) {
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
g_value_set_ulong2 (ref this, (uint) val);
break;
default:
g_value_set_ulong (ref this, new UIntPtr (val));
break;
}
}
object ToEnum ()
{
Type t = GType.LookupType (type);
if (t == null) {
if (HoldsFlags)
return g_value_get_flags (ref this);
else
return g_value_get_enum (ref this);
} else {
return (Enum) this;
}
}
object ToBoxed ()
{
IntPtr boxed_ptr = g_value_get_boxed (ref this);
if (boxed_ptr == IntPtr.Zero)
return null;
Type t = GType.LookupType (type);
if (t == null)
throw new Exception ("Unknown type " + new GType (type).ToString ());
else if (t.IsSubclassOf (typeof (GLib.Opaque)))
return (GLib.Opaque) this;
MethodInfo mi = t.GetMethod ("New", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(IntPtr) }, null);
if (mi != null)
return mi.Invoke (null, new object[] {boxed_ptr});
ConstructorInfo ci = t.GetConstructor (new Type[] { typeof(IntPtr), typeof (bool) });
if (ci != null)
return ci.Invoke (new object[] { boxed_ptr, false });
ci = t.GetConstructor (new Type[] { typeof(IntPtr) });
if (ci != null)
return ci.Invoke (new object[] { boxed_ptr });
return Marshal.PtrToStructure (boxed_ptr, t);
}
public object Val
{
get {
if (type == GType.Boolean.Val)
return (bool) this;
else if (type == GType.UChar.Val)
return (byte) this;
else if (type == GType.Char.Val)
return (sbyte) this;
else if (type == GType.Int.Val)
return (int) this;
else if (type == GType.UInt.Val)
return (uint) this;
else if (type == GType.Int64.Val)
return (long) this;
else if (type == GType.Long.Val)
return GetLongForPlatform ();
else if (type == GType.UInt64.Val)
return (ulong) this;
else if (type == GType.ULong.Val)
return GetULongForPlatform ();
else if (GType.Is (type, GType.Enum) ||
GType.Is (type, GType.Flags))
return ToEnum ();
else if (type == GType.Float.Val)
return (float) this;
else if (type == GType.Double.Val)
return (double) this;
else if (type == GType.String.Val)
return (string) this;
else if (type == GType.Pointer.Val)
return (IntPtr) this;
else if (type == GType.Variant.Val)
return (GLib.Variant) this;
else if (type == GType.Param.Val)
return g_value_get_param (ref this);
else if (type == ValueArray.GType.Val)
return new ValueArray (g_value_get_boxed (ref this));
else if (type == ManagedValue.GType.Val)
return ManagedValue.ObjectForWrapper (g_value_get_boxed (ref this));
else if (GType.Is (type, GType.Object))
return (GLib.Object) this;
else if (GType.Is (type, GType.Boxed))
return ToBoxed ();
else if (GType.LookupType (type) != null)
return ToRegisteredType ();
else if (type == IntPtr.Zero)
return null;
else
throw new Exception ("Unknown type " + new GType (type).ToString ());
}
set {
if (type == GType.Boolean.Val)
g_value_set_boolean (ref this, (bool) value);
else if (type == GType.UChar.Val)
g_value_set_uchar (ref this, (byte) value);
else if (type == GType.Char.Val)
g_value_set_char (ref this, (sbyte) value);
else if (type == GType.Int.Val)
g_value_set_int (ref this, (int) value);
else if (type == GType.UInt.Val)
g_value_set_uint (ref this, (uint) value);
else if (type == GType.Int64.Val)
g_value_set_int64 (ref this, (long) value);
else if (type == GType.Long.Val)
SetLongForPlatform ((long) value);
else if (type == GType.UInt64.Val)
g_value_set_uint64 (ref this, (ulong) value);
else if (type == GType.ULong.Val)
SetULongForPlatform (Convert.ToUInt64 (value));
else if (GType.Is (type, GType.Enum))
g_value_set_enum (ref this, (int)value);
else if (GType.Is (type, GType.Flags))
g_value_set_flags (ref this, (uint)(int)value);
else if (type == GType.Float.Val)
g_value_set_float (ref this, (float) value);
else if (type == GType.Double.Val)
g_value_set_double (ref this, (double) value);
else if (type == GType.Variant.Val) {
if (value is null)
g_value_set_variant (ref this, IntPtr.Zero);
else
g_value_set_variant (ref this, ((GLib.Variant) value).Handle);
}
else if (type == GType.String.Val) {
IntPtr native = GLib.Marshaller.StringToPtrGStrdup ((string)value);
g_value_set_string (ref this, native);
GLib.Marshaller.Free (native);
} else if (type == GType.Pointer.Val) {
if (value.GetType () == typeof (IntPtr)) {
g_value_set_pointer (ref this, (IntPtr) value);
return;
} else if (value is IWrapper) {
g_value_set_pointer (ref this, ((IWrapper)value).Handle);
return;
}
IntPtr buf = Marshal.AllocHGlobal (Marshal.SizeOf (value.GetType()));
Marshal.StructureToPtr (value, buf, false);
g_value_set_pointer (ref this, buf);
} else if (type == GType.Param.Val) {
g_value_set_param (ref this, (IntPtr) value);
} else if (type == ValueArray.GType.Val) {
g_value_set_boxed (ref this, ((ValueArray) value).Handle);
} else if (type == ManagedValue.GType.Val) {
IntPtr wrapper = ManagedValue.WrapObject (value);
g_value_set_boxed (ref this, wrapper);
ManagedValue.ReleaseWrapper (wrapper);
} else if (GType.Is (type, GType.Object))
if (value is null)
g_value_set_object (ref this, IntPtr.Zero);
else if (value is GLib.Object)
g_value_set_object (ref this, (value as GLib.Object).Handle);
else
g_value_set_object (ref this, ((GInterfaceAdapter)value).Handle);
else if (GType.Is (type, GType.Boxed)) {
if (value is null) {
g_value_set_boxed (ref this, IntPtr.Zero);
return;
}
if (value is IWrapper) {
g_value_set_boxed (ref this, ((IWrapper)value).Handle);
return;
}
IntPtr buf = Marshaller.StructureToPtrAlloc (value);
g_value_set_boxed (ref this, buf);
Marshal.FreeHGlobal (buf);
} else if (GLib.GType.LookupType (type) != null) {
FromRegisteredType (value);
} else
throw new Exception ("Unknown type " + new GType (type).ToString ());
}
}
internal void Update (object val)
{
if (GType.Is (type, GType.Boxed) && val != null && !(val is IWrapper)) {
MethodInfo mi = val.GetType ().GetMethod ("Update", BindingFlags.NonPublic | BindingFlags.Instance);
IntPtr boxed_ptr = g_value_get_boxed (ref this);
if (mi == null && !val.GetType ().IsDefined (typeof(StructLayoutAttribute), false))
return;
if (mi == null)
Marshal.StructureToPtr (val, boxed_ptr, false);
else
mi.Invoke (val, null);
}
}
bool HoldsFlags {
get { return g_type_check_value_holds (ref this, GType.Flags.Val); }
}
void InitForProperty (Object obj, string name)
{
GType gtype = obj.NativeType;
InitForProperty (gtype, name);
}
void InitForProperty (GType gtype, string name)
{
IntPtr p_name = Marshaller.StringToPtrGStrdup (name);
IntPtr spec_ptr = g_object_class_find_property (gtype.GetClassPtr (), p_name);
Marshaller.Free (p_name);
if (spec_ptr == IntPtr.Zero)
throw new Exception (String.Format ("No property with name '{0}' in type '{1}'", name, gtype.ToString()));
ParamSpec spec = new ParamSpec (spec_ptr);
g_value_init (ref this, spec.ValueType.Val);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_object_class_find_property(IntPtr klass, IntPtr name);
static d_g_object_class_find_property g_object_class_find_property = FuncLoader.LoadFunction<d_g_object_class_find_property>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_class_find_property"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_type_check_value_holds(ref Value val, IntPtr gtype);
static d_g_type_check_value_holds g_type_check_value_holds = FuncLoader.LoadFunction<d_g_type_check_value_holds>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_type_check_value_holds"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_init(ref GLib.Value val, IntPtr gtype);
static d_g_value_init g_value_init = FuncLoader.LoadFunction<d_g_value_init>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_init"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_unset(ref GLib.Value val);
static d_g_value_unset g_value_unset = FuncLoader.LoadFunction<d_g_value_unset>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_unset"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_boolean(ref Value val, bool data);
static d_g_value_set_boolean g_value_set_boolean = FuncLoader.LoadFunction<d_g_value_set_boolean>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_boolean"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_uchar(ref Value val, byte data);
static d_g_value_set_uchar g_value_set_uchar = FuncLoader.LoadFunction<d_g_value_set_uchar>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_uchar"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_char(ref Value val, sbyte data);
static d_g_value_set_char g_value_set_char = FuncLoader.LoadFunction<d_g_value_set_char>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_char"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_boxed(ref Value val, IntPtr data);
static d_g_value_set_boxed g_value_set_boxed = FuncLoader.LoadFunction<d_g_value_set_boxed>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_boxed"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_double(ref Value val, double data);
static d_g_value_set_double g_value_set_double = FuncLoader.LoadFunction<d_g_value_set_double>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_double"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_float(ref Value val, float data);
static d_g_value_set_float g_value_set_float = FuncLoader.LoadFunction<d_g_value_set_float>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_float"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_int(ref Value val, int data);
static d_g_value_set_int g_value_set_int = FuncLoader.LoadFunction<d_g_value_set_int>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_int"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_int64(ref Value val, long data);
static d_g_value_set_int64 g_value_set_int64 = FuncLoader.LoadFunction<d_g_value_set_int64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_int64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_long(ref Value val, IntPtr data);
static d_g_value_set_long g_value_set_long = FuncLoader.LoadFunction<d_g_value_set_long>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_long"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_long2(ref Value val, int data);
static d_g_value_set_long2 g_value_set_long2 = FuncLoader.LoadFunction<d_g_value_set_long2>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_long"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_uint64(ref Value val, ulong data);
static d_g_value_set_uint64 g_value_set_uint64 = FuncLoader.LoadFunction<d_g_value_set_uint64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_uint64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_object(ref Value val, IntPtr data);
static d_g_value_set_object g_value_set_object = FuncLoader.LoadFunction<d_g_value_set_object>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_object"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_param(ref Value val, IntPtr data);
static d_g_value_set_param g_value_set_param = FuncLoader.LoadFunction<d_g_value_set_param>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_param"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_pointer(ref Value val, IntPtr data);
static d_g_value_set_pointer g_value_set_pointer = FuncLoader.LoadFunction<d_g_value_set_pointer>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_pointer"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_string(ref Value val, IntPtr data);
static d_g_value_set_string g_value_set_string = FuncLoader.LoadFunction<d_g_value_set_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_string"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_uint(ref Value val, uint data);
static d_g_value_set_uint g_value_set_uint = FuncLoader.LoadFunction<d_g_value_set_uint>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_uint"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_ulong(ref Value val, UIntPtr data);
static d_g_value_set_ulong g_value_set_ulong = FuncLoader.LoadFunction<d_g_value_set_ulong>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_ulong"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_ulong2(ref Value val, uint data);
static d_g_value_set_ulong2 g_value_set_ulong2 = FuncLoader.LoadFunction<d_g_value_set_ulong2>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_ulong"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_enum(ref Value val, int data);
static d_g_value_set_enum g_value_set_enum = FuncLoader.LoadFunction<d_g_value_set_enum>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_enum"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_flags(ref Value val, uint data);
static d_g_value_set_flags g_value_set_flags = FuncLoader.LoadFunction<d_g_value_set_flags>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_flags"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_set_variant(ref Value val, IntPtr data);
static d_g_value_set_variant g_value_set_variant = FuncLoader.LoadFunction<d_g_value_set_variant>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_set_variant"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_value_get_boolean(ref Value val);
static d_g_value_get_boolean g_value_get_boolean = FuncLoader.LoadFunction<d_g_value_get_boolean>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_boolean"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate byte d_g_value_get_uchar(ref Value val);
static d_g_value_get_uchar g_value_get_uchar = FuncLoader.LoadFunction<d_g_value_get_uchar>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_uchar"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate sbyte d_g_value_get_char(ref Value val);
static d_g_value_get_char g_value_get_char = FuncLoader.LoadFunction<d_g_value_get_char>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_char"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_get_boxed(ref Value val);
static d_g_value_get_boxed g_value_get_boxed = FuncLoader.LoadFunction<d_g_value_get_boxed>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_boxed"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate double d_g_value_get_double(ref Value val);
static d_g_value_get_double g_value_get_double = FuncLoader.LoadFunction<d_g_value_get_double>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_double"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate float d_g_value_get_float(ref Value val);
static d_g_value_get_float g_value_get_float = FuncLoader.LoadFunction<d_g_value_get_float>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_float"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate GLib.GType d_g_value_get_gtype(ref Value val);
static d_g_value_get_gtype g_value_get_gtype = FuncLoader.LoadFunction<d_g_value_get_gtype>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_gtype"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_value_get_int(ref Value val);
static d_g_value_get_int g_value_get_int = FuncLoader.LoadFunction<d_g_value_get_int>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_int"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate long d_g_value_get_int64(ref Value val);
static d_g_value_get_int64 g_value_get_int64 = FuncLoader.LoadFunction<d_g_value_get_int64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_int64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_get_long(ref Value val);
static d_g_value_get_long g_value_get_long = FuncLoader.LoadFunction<d_g_value_get_long>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_long"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_value_get_long_as_int(ref Value val);
static d_g_value_get_long_as_int g_value_get_long_as_int = FuncLoader.LoadFunction<d_g_value_get_long_as_int>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_long"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate ulong d_g_value_get_uint64(ref Value val);
static d_g_value_get_uint64 g_value_get_uint64 = FuncLoader.LoadFunction<d_g_value_get_uint64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_uint64"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate UIntPtr d_g_value_get_ulong(ref Value val);
static d_g_value_get_ulong g_value_get_ulong = FuncLoader.LoadFunction<d_g_value_get_ulong>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_ulong"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_value_get_ulong_as_uint(ref Value val);
static d_g_value_get_ulong_as_uint g_value_get_ulong_as_uint = FuncLoader.LoadFunction<d_g_value_get_ulong_as_uint>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_ulong"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_get_object(ref Value val);
static d_g_value_get_object g_value_get_object = FuncLoader.LoadFunction<d_g_value_get_object>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_object"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_get_param(ref Value val);
static d_g_value_get_param g_value_get_param = FuncLoader.LoadFunction<d_g_value_get_param>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_param"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_get_pointer(ref Value val);
static d_g_value_get_pointer g_value_get_pointer = FuncLoader.LoadFunction<d_g_value_get_pointer>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_pointer"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_get_string(ref Value val);
static d_g_value_get_string g_value_get_string = FuncLoader.LoadFunction<d_g_value_get_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_string"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_value_get_uint(ref Value val);
static d_g_value_get_uint g_value_get_uint = FuncLoader.LoadFunction<d_g_value_get_uint>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_uint"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_value_get_enum(ref Value val);
static d_g_value_get_enum g_value_get_enum = FuncLoader.LoadFunction<d_g_value_get_enum>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_enum"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_value_get_flags(ref Value val);
static d_g_value_get_flags g_value_get_flags = FuncLoader.LoadFunction<d_g_value_get_flags>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_flags"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_strv_get_type();
static d_g_strv_get_type g_strv_get_type = FuncLoader.LoadFunction<d_g_strv_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_strv_get_type"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_get_variant(ref Value val);
static d_g_value_get_variant g_value_get_variant = FuncLoader.LoadFunction<d_g_value_get_variant>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_get_variant"));
}
}

View File

@@ -0,0 +1,249 @@
// ValueArray.cs - ValueArray wrapper implementation
//
// Authors: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2003 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GLib {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public class ValueArray : IDisposable, ICollection, ICloneable, IWrapper {
private IntPtr handle = IntPtr.Zero;
static private IList<IntPtr> PendingFrees = new List<IntPtr> ();
static private bool idle_queued = false;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_array_new(uint n_preallocs);
static d_g_value_array_new g_value_array_new = FuncLoader.LoadFunction<d_g_value_array_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_new"));
public ValueArray (uint n_preallocs)
{
handle = g_value_array_new (n_preallocs);
}
public ValueArray (IntPtr raw)
{
handle = g_value_array_copy (raw);
}
~ValueArray ()
{
Dispose (false);
}
// IDisposable
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_array_free(IntPtr raw);
static d_g_value_array_free g_value_array_free = FuncLoader.LoadFunction<d_g_value_array_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_free"));
void Dispose (bool disposing)
{
if (Handle == IntPtr.Zero)
return;
lock (PendingFrees) {
PendingFrees.Add (handle);
if (! idle_queued) {
Timeout.Add (50, new TimeoutHandler (PerformFrees));
idle_queued = true;
}
}
handle = IntPtr.Zero;
}
static bool PerformFrees ()
{
IntPtr[] handles;
lock (PendingFrees) {
idle_queued = false;
handles = new IntPtr [PendingFrees.Count];
PendingFrees.CopyTo (handles, 0);
PendingFrees.Clear ();
}
foreach (IntPtr h in handles)
g_value_array_free (h);
return false;
}
public IntPtr Handle {
get {
return handle;
}
}
struct NativeStruct {
public uint n_values;
public IntPtr values;
public uint n_prealloced;
}
NativeStruct Native {
get { return (NativeStruct) Marshal.PtrToStructure (Handle, typeof(NativeStruct)); }
}
public IntPtr ArrayPtr {
get { return Native.values; }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_array_append(IntPtr raw, ref GLib.Value val);
static d_g_value_array_append g_value_array_append = FuncLoader.LoadFunction<d_g_value_array_append>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_append"));
public void Append (GLib.Value val)
{
g_value_array_append (Handle, ref val);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_array_insert(IntPtr raw, uint idx, ref GLib.Value val);
static d_g_value_array_insert g_value_array_insert = FuncLoader.LoadFunction<d_g_value_array_insert>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_insert"));
public void Insert (uint idx, GLib.Value val)
{
g_value_array_insert (Handle, idx, ref val);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_array_prepend(IntPtr raw, ref GLib.Value val);
static d_g_value_array_prepend g_value_array_prepend = FuncLoader.LoadFunction<d_g_value_array_prepend>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_prepend"));
public void Prepend (GLib.Value val)
{
g_value_array_prepend (Handle, ref val);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_value_array_remove(IntPtr raw, uint idx);
static d_g_value_array_remove g_value_array_remove = FuncLoader.LoadFunction<d_g_value_array_remove>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_remove"));
public void Remove (uint idx)
{
g_value_array_remove (Handle, idx);
}
// ICollection
public int Count {
get { return (int) Native.n_values; }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_array_get_nth(IntPtr raw, uint idx);
static d_g_value_array_get_nth g_value_array_get_nth = FuncLoader.LoadFunction<d_g_value_array_get_nth>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_get_nth"));
public object this [int index] {
get {
IntPtr raw_val = g_value_array_get_nth (Handle, (uint) index);
return Marshal.PtrToStructure (raw_val, typeof (GLib.Value));
}
}
// Synchronization could be tricky here. Hmm.
public bool IsSynchronized {
get { return false; }
}
public object SyncRoot {
get { return null; }
}
public void CopyTo (Array array, int index)
{
if (array == null)
throw new ArgumentNullException ("Array can't be null.");
if (index < 0)
throw new ArgumentOutOfRangeException ("Index must be greater than 0.");
if (index + Count < array.Length)
throw new ArgumentException ("Array not large enough to copy into starting at index.");
for (int i = 0; i < Count; i++)
((IList) array) [index + i] = this [i];
}
private class ListEnumerator : IEnumerator
{
private int current = -1;
private ValueArray vals;
public ListEnumerator (ValueArray vals)
{
this.vals = vals;
}
public object Current {
get {
if (current == -1)
return null;
return vals [current];
}
}
public bool MoveNext ()
{
if (++current >= vals.Count) {
current = -1;
return false;
}
return true;
}
public void Reset ()
{
current = -1;
}
}
// IEnumerable
public IEnumerator GetEnumerator ()
{
return new ListEnumerator (this);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_array_copy(IntPtr raw);
static d_g_value_array_copy g_value_array_copy = FuncLoader.LoadFunction<d_g_value_array_copy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_copy"));
// ICloneable
public object Clone ()
{
return new ValueArray (g_value_array_copy (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_value_array_get_type();
static d_g_value_array_get_type g_value_array_get_type = FuncLoader.LoadFunction<d_g_value_array_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_value_array_get_type"));
public static GLib.GType GType {
get {
return new GLib.GType (g_value_array_get_type ());
}
}
}
}

View File

@@ -0,0 +1,344 @@
// Copyright (c) 2011 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
namespace GLib {
public class Variant : IDisposable {
IntPtr handle;
public IntPtr Handle {
get { return handle; }
}
// Docs say that GVariant is threadsafe.
~Variant ()
{
Dispose (false);
}
public void Dispose ()
{
Dispose (true);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_variant_unref(IntPtr handle);
static d_g_variant_unref g_variant_unref = FuncLoader.LoadFunction<d_g_variant_unref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_unref"));
void Dispose (bool disposing)
{
if (handle == IntPtr.Zero)
return;
g_variant_unref (handle);
handle = IntPtr.Zero;
if (disposing)
GC.SuppressFinalize (this);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_ref_sink(IntPtr handle);
static d_g_variant_ref_sink g_variant_ref_sink = FuncLoader.LoadFunction<d_g_variant_ref_sink>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_ref_sink"));
public Variant (IntPtr handle)
{
this.handle = g_variant_ref_sink (handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_get_type(IntPtr val);
static d_g_variant_get_type g_variant_get_type = FuncLoader.LoadFunction<d_g_variant_get_type>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_type"));
VariantType type;
public VariantType Type {
get {
if (type == null)
type = new VariantType (g_variant_get_type (Handle));
return type;
}
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_variant(IntPtr val);
static d_g_variant_new_variant g_variant_new_variant = FuncLoader.LoadFunction<d_g_variant_new_variant>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_variant"));
public static Variant NewVariant (Variant val) {
return new Variant (g_variant_new_variant (val.Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_boolean(bool val);
static d_g_variant_new_boolean g_variant_new_boolean = FuncLoader.LoadFunction<d_g_variant_new_boolean>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_boolean"));
public Variant (bool val) : this (g_variant_new_boolean (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_byte(byte val);
static d_g_variant_new_byte g_variant_new_byte = FuncLoader.LoadFunction<d_g_variant_new_byte>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_byte"));
public Variant (byte val) : this (g_variant_new_byte (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_int16(short val);
static d_g_variant_new_int16 g_variant_new_int16 = FuncLoader.LoadFunction<d_g_variant_new_int16>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_int16"));
public Variant (short val) : this (g_variant_new_int16 (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_uint16(ushort val);
static d_g_variant_new_uint16 g_variant_new_uint16 = FuncLoader.LoadFunction<d_g_variant_new_uint16>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_uint16"));
public Variant (ushort val) : this (g_variant_new_uint16 (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_int32(int val);
static d_g_variant_new_int32 g_variant_new_int32 = FuncLoader.LoadFunction<d_g_variant_new_int32>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_int32"));
public Variant (int val) : this (g_variant_new_int32 (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_uint32(uint val);
static d_g_variant_new_uint32 g_variant_new_uint32 = FuncLoader.LoadFunction<d_g_variant_new_uint32>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_uint32"));
public Variant (uint val) : this (g_variant_new_uint32 (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_int64(long val);
static d_g_variant_new_int64 g_variant_new_int64 = FuncLoader.LoadFunction<d_g_variant_new_int64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_int64"));
public Variant (long val) : this (g_variant_new_int64 (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_uint64(ulong val);
static d_g_variant_new_uint64 g_variant_new_uint64 = FuncLoader.LoadFunction<d_g_variant_new_uint64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_uint64"));
public Variant (ulong val) : this (g_variant_new_uint64 (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_double(double val);
static d_g_variant_new_double g_variant_new_double = FuncLoader.LoadFunction<d_g_variant_new_double>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_double"));
public Variant (double val) : this (g_variant_new_double (val)) {}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_string(IntPtr val);
static d_g_variant_new_string g_variant_new_string = FuncLoader.LoadFunction<d_g_variant_new_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_string"));
public Variant (string val)
{
IntPtr native_val = Marshaller.StringToPtrGStrdup (val);
handle = g_variant_ref_sink (g_variant_new_string (native_val));
Marshaller.Free (native_val);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_strv(IntPtr[] strv, IntPtr length);
static d_g_variant_new_strv g_variant_new_strv = FuncLoader.LoadFunction<d_g_variant_new_strv>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_strv"));
public Variant (string[] strv)
{
IntPtr[] native = Marshaller.StringArrayToNullTermPointer (strv);
handle = g_variant_ref_sink (g_variant_new_strv (native, new IntPtr ((long) strv.Length)));
Marshaller.Free (native);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_tuple(IntPtr[] children, UIntPtr n_children);
static d_g_variant_new_tuple g_variant_new_tuple = FuncLoader.LoadFunction<d_g_variant_new_tuple>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_tuple"));
public static Variant NewTuple (Variant[] children)
{
if (children == null)
return new Variant (g_variant_new_tuple (null, new UIntPtr (0ul)));
IntPtr[] native = new IntPtr[children.Length];
for (int i = 0; i < children.Length; i++)
native[i] = children[i].Handle;
return new Variant (g_variant_new_tuple (native, new UIntPtr ((ulong) children.Length)));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_array(IntPtr child_type, IntPtr[] children, UIntPtr n_children);
static d_g_variant_new_array g_variant_new_array = FuncLoader.LoadFunction<d_g_variant_new_array>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_array"));
public static Variant NewArray (Variant[] children)
{
if (children == null) {
throw new ArgumentNullException ("children", "To create an empty array use NewArray (VariantType.<Type>, null)");
}
return NewArray (null, children);
}
public static Variant NewArray (VariantType type, Variant[] children)
{
if (children == null) {
if (type == null) {
throw new ArgumentException ("The type and children parameters cannot be both null");
} else {
return new Variant (g_variant_new_array (type.Handle, null, new UIntPtr (0ul)));
}
}
IntPtr[] native = new IntPtr[children.Length];
for (int i = 0; i < children.Length; i++)
native[i] = children[i].Handle;
return new Variant (g_variant_new_array (type == null ? (IntPtr) null : type.Handle,
native, new UIntPtr ((ulong) children.Length)));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_new_dict_entry(IntPtr k, IntPtr v);
static d_g_variant_new_dict_entry g_variant_new_dict_entry = FuncLoader.LoadFunction<d_g_variant_new_dict_entry>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_new_dict_entry"));
public static Variant NewDictEntry (Variant k, Variant v)
{
return new Variant (g_variant_new_dict_entry (k.Handle, v.Handle));
}
public Variant (IDictionary<string, Variant> dict)
{
VariantType type = VariantType.NewDictionaryEntry (
VariantType.String,
VariantType.Variant);
var pairs = new List<Variant> ();
foreach (var kvp in dict)
pairs.Add (NewDictEntry (new Variant (kvp.Key), NewVariant (kvp.Value)));
handle = g_variant_ref_sink (NewArray (type, pairs.ToArray ()).Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_get_boolean(IntPtr handle);
static d_g_variant_get_boolean g_variant_get_boolean = FuncLoader.LoadFunction<d_g_variant_get_boolean>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_boolean"));
public static explicit operator bool (Variant val)
{
return g_variant_get_boolean (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate byte d_g_variant_get_byte(IntPtr handle);
static d_g_variant_get_byte g_variant_get_byte = FuncLoader.LoadFunction<d_g_variant_get_byte>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_byte"));
public static explicit operator byte (Variant val)
{
return g_variant_get_byte (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate short d_g_variant_get_int16(IntPtr handle);
static d_g_variant_get_int16 g_variant_get_int16 = FuncLoader.LoadFunction<d_g_variant_get_int16>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_int16"));
public static explicit operator short (Variant val)
{
return g_variant_get_int16 (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate ushort d_g_variant_get_uint16(IntPtr handle);
static d_g_variant_get_uint16 g_variant_get_uint16 = FuncLoader.LoadFunction<d_g_variant_get_uint16>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_uint16"));
public static explicit operator ushort (Variant val)
{
return g_variant_get_uint16 (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_variant_get_int32(IntPtr handle);
static d_g_variant_get_int32 g_variant_get_int32 = FuncLoader.LoadFunction<d_g_variant_get_int32>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_int32"));
public static explicit operator int (Variant val)
{
return g_variant_get_int32 (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate uint d_g_variant_get_uint32(IntPtr handle);
static d_g_variant_get_uint32 g_variant_get_uint32 = FuncLoader.LoadFunction<d_g_variant_get_uint32>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_uint32"));
public static explicit operator uint (Variant val)
{
return g_variant_get_uint32 (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate long d_g_variant_get_int64(IntPtr handle);
static d_g_variant_get_int64 g_variant_get_int64 = FuncLoader.LoadFunction<d_g_variant_get_int64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_int64"));
public static explicit operator long (Variant val)
{
return g_variant_get_int64 (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate ulong d_g_variant_get_uint64(IntPtr handle);
static d_g_variant_get_uint64 g_variant_get_uint64 = FuncLoader.LoadFunction<d_g_variant_get_uint64>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_uint64"));
public static explicit operator ulong (Variant val)
{
return g_variant_get_uint64 (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate double d_g_variant_get_double(IntPtr handle);
static d_g_variant_get_double g_variant_get_double = FuncLoader.LoadFunction<d_g_variant_get_double>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_double"));
public static explicit operator double (Variant val)
{
return g_variant_get_double (val.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_get_string(IntPtr handle, IntPtr length);
static d_g_variant_get_string g_variant_get_string = FuncLoader.LoadFunction<d_g_variant_get_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_string"));
public static explicit operator string (Variant val)
{
IntPtr str = g_variant_get_string (val.Handle, IntPtr.Zero);
return GLib.Marshaller.Utf8PtrToString (str);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_print(IntPtr variant, bool type_annotate);
static d_g_variant_print g_variant_print = FuncLoader.LoadFunction<d_g_variant_print>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_print"));
public string Print (bool type_annotate)
{
IntPtr str = g_variant_print (handle, type_annotate);
return Marshaller.PtrToStringGFree (str);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_n_children(IntPtr handle);
static d_g_variant_n_children g_variant_n_children = FuncLoader.LoadFunction<d_g_variant_n_children>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_n_children"));
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_get_child_value(IntPtr handle, IntPtr index);
static d_g_variant_get_child_value g_variant_get_child_value = FuncLoader.LoadFunction<d_g_variant_get_child_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_child_value"));
public Variant[] ToArray ()
{
var n_children = (long) g_variant_n_children (Handle);
var ret = new Variant[n_children];
for (long i = 0; i < n_children; i++) {
var h = g_variant_get_child_value (Handle, new IntPtr (i));
ret[i] = new Variant (h);
g_variant_unref (h);
}
return ret;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_get_variant(IntPtr handle);
static d_g_variant_get_variant g_variant_get_variant = FuncLoader.LoadFunction<d_g_variant_get_variant>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_get_variant"));
public Dictionary<string, Variant> ToAsv ()
{
var ret = new Dictionary<string, Variant> ();
foreach (var dictEntry in ToArray ()) {
var pair = dictEntry.ToArray ();
var key = (string) pair[0];
var h = g_variant_get_variant (pair[1].Handle);
var value = new Variant (h);
g_variant_unref (h);
ret.Add (key, value);
}
return ret;
}
}
}

View File

@@ -0,0 +1,298 @@
// Copyright (c) 2011 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
using System;
using System.Runtime.InteropServices;
namespace GLib {
public class VariantType : IDisposable {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_string_is_valid(IntPtr type_string);
static d_g_variant_type_string_is_valid g_variant_type_string_is_valid = FuncLoader.LoadFunction<d_g_variant_type_string_is_valid>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_string_is_valid"));
public static bool StringIsValid (string type_string)
{
IntPtr native = Marshaller.StringToPtrGStrdup (type_string);
bool ret = g_variant_type_string_is_valid (native);
Marshaller.Free (native);
return ret;
}
private VariantType () {}
IntPtr handle;
public IntPtr Handle {
get { return handle; }
}
// Docs say that GVariant is threadsafe.
~VariantType ()
{
Dispose (false);
}
public void Dispose ()
{
Dispose (true);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void d_g_variant_type_free(IntPtr handle);
static d_g_variant_type_free g_variant_type_free = FuncLoader.LoadFunction<d_g_variant_type_free>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_free"));
void Dispose (bool disposing)
{
if (handle == IntPtr.Zero)
return;
g_variant_type_free (handle);
handle = IntPtr.Zero;
if (disposing)
GC.SuppressFinalize (this);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_copy(IntPtr handle);
static d_g_variant_type_copy g_variant_type_copy = FuncLoader.LoadFunction<d_g_variant_type_copy>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_copy"));
public VariantType (IntPtr handle)
{
this.handle = g_variant_type_copy (handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_new(IntPtr type_name);
static d_g_variant_type_new g_variant_type_new = FuncLoader.LoadFunction<d_g_variant_type_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_new"));
public VariantType (string type_string)
{
IntPtr native = Marshaller.StringToPtrGStrdup (type_string);
handle = g_variant_type_new (native);
Marshaller.Free (native);
}
public VariantType Copy ()
{
return new VariantType (Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_equal(IntPtr a, IntPtr b);
static d_g_variant_type_equal g_variant_type_equal = FuncLoader.LoadFunction<d_g_variant_type_equal>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_equal"));
public override bool Equals (object o)
{
return (o is VariantType) && g_variant_type_equal (Handle, (o as VariantType).Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate int d_g_variant_type_hash(IntPtr a);
static d_g_variant_type_hash g_variant_type_hash = FuncLoader.LoadFunction<d_g_variant_type_hash>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_hash"));
public override int GetHashCode ()
{
return g_variant_type_hash (Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_peek_string(IntPtr a);
static d_g_variant_type_peek_string g_variant_type_peek_string = FuncLoader.LoadFunction<d_g_variant_type_peek_string>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_peek_string"));
public override string ToString ()
{
return Marshaller.Utf8PtrToString (g_variant_type_peek_string (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_array(IntPtr type);
static d_g_variant_type_is_array g_variant_type_is_array = FuncLoader.LoadFunction<d_g_variant_type_is_array>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_array"));
public bool IsArray {
get { return g_variant_type_is_array (Handle); }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_basic(IntPtr type);
static d_g_variant_type_is_basic g_variant_type_is_basic = FuncLoader.LoadFunction<d_g_variant_type_is_basic>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_basic"));
public bool IsBasic {
get { return g_variant_type_is_basic (Handle); }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_container(IntPtr type);
static d_g_variant_type_is_container g_variant_type_is_container = FuncLoader.LoadFunction<d_g_variant_type_is_container>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_container"));
public bool IsContainer {
get { return g_variant_type_is_container (Handle); }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_definite(IntPtr type);
static d_g_variant_type_is_definite g_variant_type_is_definite = FuncLoader.LoadFunction<d_g_variant_type_is_definite>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_definite"));
public bool IsDefinite {
get { return g_variant_type_is_definite (Handle); }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_dict_entry(IntPtr type);
static d_g_variant_type_is_dict_entry g_variant_type_is_dict_entry = FuncLoader.LoadFunction<d_g_variant_type_is_dict_entry>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_dict_entry"));
public bool IsDictionaryEntry {
get { return g_variant_type_is_dict_entry (Handle); }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_maybe(IntPtr type);
static d_g_variant_type_is_maybe g_variant_type_is_maybe = FuncLoader.LoadFunction<d_g_variant_type_is_maybe>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_maybe"));
public bool IsMaybe {
get { return g_variant_type_is_maybe (Handle); }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_tuple(IntPtr type);
static d_g_variant_type_is_tuple g_variant_type_is_tuple = FuncLoader.LoadFunction<d_g_variant_type_is_tuple>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_tuple"));
public bool IsTuple {
get { return g_variant_type_is_tuple (Handle); }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_variant(IntPtr type);
static d_g_variant_type_is_variant g_variant_type_is_variant = FuncLoader.LoadFunction<d_g_variant_type_is_variant>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_variant"));
public bool IsVariant {
get { return g_variant_type_is_variant (Handle); }
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool d_g_variant_type_is_subtype_of(IntPtr type, IntPtr supertype);
static d_g_variant_type_is_subtype_of g_variant_type_is_subtype_of = FuncLoader.LoadFunction<d_g_variant_type_is_subtype_of>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_is_subtype_of"));
public bool IsSubtypeOf (VariantType supertype)
{
return g_variant_type_is_subtype_of (Handle, supertype == null ? IntPtr.Zero : supertype.Handle);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_element(IntPtr type);
static d_g_variant_type_element g_variant_type_element = FuncLoader.LoadFunction<d_g_variant_type_element>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_element"));
public VariantType Element ()
{
return new VariantType (g_variant_type_element (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_first(IntPtr type);
static d_g_variant_type_first g_variant_type_first = FuncLoader.LoadFunction<d_g_variant_type_first>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_first"));
public VariantType First ()
{
return new VariantType (g_variant_type_first (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_next(IntPtr type);
static d_g_variant_type_next g_variant_type_next = FuncLoader.LoadFunction<d_g_variant_type_next>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_next"));
public VariantType Next ()
{
return new VariantType (g_variant_type_next (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_n_items(IntPtr type);
static d_g_variant_type_n_items g_variant_type_n_items = FuncLoader.LoadFunction<d_g_variant_type_n_items>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_n_items"));
public long NItems ()
{
return g_variant_type_n_items (Handle).ToInt64 ();
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_key(IntPtr type);
static d_g_variant_type_key g_variant_type_key = FuncLoader.LoadFunction<d_g_variant_type_key>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_key"));
public VariantType Key ()
{
return new VariantType (g_variant_type_key (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_value(IntPtr type);
static d_g_variant_type_value g_variant_type_value = FuncLoader.LoadFunction<d_g_variant_type_value>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_value"));
public VariantType Value ()
{
return new VariantType (g_variant_type_value (Handle));
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_new_array(IntPtr element);
static d_g_variant_type_new_array g_variant_type_new_array = FuncLoader.LoadFunction<d_g_variant_type_new_array>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_new_array"));
public static VariantType NewArray (VariantType element)
{
VariantType result = new VariantType ();
result.handle = g_variant_type_new_array (element == null ? IntPtr.Zero : element.Handle);
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_new_dict_entry(IntPtr key, IntPtr value);
static d_g_variant_type_new_dict_entry g_variant_type_new_dict_entry = FuncLoader.LoadFunction<d_g_variant_type_new_dict_entry>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_new_dict_entry"));
public static VariantType NewDictionaryEntry (VariantType key, VariantType value)
{
VariantType result = new VariantType ();
result.handle = g_variant_type_new_dict_entry (key == null ? IntPtr.Zero : key.Handle, value == null ? IntPtr.Zero : value.Handle);
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_new_maybe(IntPtr element);
static d_g_variant_type_new_maybe g_variant_type_new_maybe = FuncLoader.LoadFunction<d_g_variant_type_new_maybe>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_new_maybe"));
public static VariantType NewMaybe (VariantType element)
{
VariantType result = new VariantType ();
result.handle = g_variant_type_new_maybe (element == null ? IntPtr.Zero : element.Handle);
return result;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate IntPtr d_g_variant_type_new_tuple(IntPtr[] items, int n_items);
static d_g_variant_type_new_tuple g_variant_type_new_tuple = FuncLoader.LoadFunction<d_g_variant_type_new_tuple>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_variant_type_new_tuple"));
public static VariantType NewTuple (VariantType[] items)
{
VariantType result = new VariantType ();
IntPtr[] native = new IntPtr [items.Length];
for (int i = 0; i < items.Length; i++)
native [i] = items [i].Handle;
result.handle = g_variant_type_new_tuple (native, native.Length);
return result;
}
// These fields depend on function pointers and therefore must be placed below them.
public static VariantType Boolean = new VariantType ("b");
public static VariantType Byte = new VariantType ("y");
public static VariantType Int16 = new VariantType ("n");
public static VariantType UInt16 = new VariantType ("q");
public static VariantType Int32 = new VariantType ("i");
public static VariantType Uint32 = new VariantType ("u");
public static VariantType Int64 = new VariantType ("x");
public static VariantType UInt64 = new VariantType ("t");
public static VariantType Double = new VariantType ("d");
public static VariantType String = new VariantType ("s");
public static VariantType Path = new VariantType ("o");
public static VariantType Signature = new VariantType ("g");
public static VariantType Variant = new VariantType ("v");
public static VariantType HandleType = new VariantType ("h");
public static VariantType Unit = new VariantType ("()");
public static VariantType Any = new VariantType ("*");
public static VariantType Basic = new VariantType ("?");
public static VariantType Maybe = new VariantType ("m*");
public static VariantType Array = new VariantType ("a*");
public static VariantType Tuple = new VariantType ("r");
public static VariantType DictEntry = new VariantType ("{?*}");
public static VariantType Dictionary = new VariantType ("a{?*}");
public static VariantType StringArray = new VariantType ("as");
public static VariantType ByteString = new VariantType ("ay");
public static VariantType ByteStringArray = new VariantType ("aay");
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]

View File

@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("GLibSharp")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("GLibSharp is a C# wrapper for the GLib library.")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b7303616129ab5a0ca64def45649ab522d83fa4a")]
[assembly: System.Reflection.AssemblyProductAttribute("GLibSharp")]
[assembly: System.Reflection.AssemblyTitleAttribute("GLibSharp")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/GtkSharp/GtkSharp")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.

View File

@@ -0,0 +1 @@
10c3f26e482772b2d17752ff394159f76b11d2401b9d80684f8ddb6e9764060f

View File

@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = GLibSharp
build_property.ProjectDir = E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =

View File

@@ -0,0 +1 @@
282b3b24405fb2a10836acb7a59c3ed0d1a633e2916a6480f78a5b9d1f9dd25d

View File

@@ -0,0 +1,12 @@
E:\projects\KioskApp\GtkSharp\BuildOutput\Debug\net8.0\GLibSharp.deps.json
E:\projects\KioskApp\GtkSharp\BuildOutput\Debug\net8.0\GLibSharp.dll
E:\projects\KioskApp\GtkSharp\BuildOutput\Debug\net8.0\GLibSharp.pdb
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\GLibSharp.GeneratedMSBuildEditorConfig.editorconfig
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\GLibSharp.AssemblyInfoInputs.cache
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\GLibSharp.AssemblyInfo.cs
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\GLibSharp.csproj.CoreCompileInputs.cache
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\GLibSharp.sourcelink.json
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\GLibSharp.dll
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\refint\GLibSharp.dll
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\GLibSharp.pdb
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\net8.0\ref\GLibSharp.dll

View File

@@ -0,0 +1 @@
{"documents":{"E:\\projects\\KioskApp\\GtkSharp\\*":"https://raw.githubusercontent.com/GtkSharp/GtkSharp/b7303616129ab5a0ca64def45649ab522d83fa4a/*"}}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]

View File

@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("GLibSharp")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("GLibSharp is a C# wrapper for the GLib library.")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b7303616129ab5a0ca64def45649ab522d83fa4a")]
[assembly: System.Reflection.AssemblyProductAttribute("GLibSharp")]
[assembly: System.Reflection.AssemblyTitleAttribute("GLibSharp")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/GtkSharp/GtkSharp")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.

View File

@@ -0,0 +1 @@
10c3f26e482772b2d17752ff394159f76b11d2401b9d80684f8ddb6e9764060f

View File

@@ -0,0 +1,5 @@
is_global = true
build_property.RootNamespace = GLibSharp
build_property.ProjectDir = E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =

View File

@@ -0,0 +1 @@
93644bea7b70b367eebc481d0b663bfbe7c2df17a9b47ca7653544777a2a52fb

View File

@@ -0,0 +1,11 @@
E:\projects\KioskApp\GtkSharp\BuildOutput\Debug\netstandard2.0\GLibSharp.deps.json
E:\projects\KioskApp\GtkSharp\BuildOutput\Debug\netstandard2.0\GLibSharp.dll
E:\projects\KioskApp\GtkSharp\BuildOutput\Debug\netstandard2.0\GLibSharp.pdb
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\netstandard2.0\GLibSharp.csproj.AssemblyReference.cache
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\netstandard2.0\GLibSharp.GeneratedMSBuildEditorConfig.editorconfig
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\netstandard2.0\GLibSharp.AssemblyInfoInputs.cache
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\netstandard2.0\GLibSharp.AssemblyInfo.cs
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\netstandard2.0\GLibSharp.csproj.CoreCompileInputs.cache
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\netstandard2.0\GLibSharp.sourcelink.json
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\netstandard2.0\GLibSharp.dll
E:\projects\KioskApp\GtkSharp\Source\Libs\GLibSharp\obj\Debug\netstandard2.0\GLibSharp.pdb

View File

@@ -0,0 +1 @@
{"documents":{"E:\\projects\\KioskApp\\GtkSharp\\*":"https://raw.githubusercontent.com/GtkSharp/GtkSharp/b7303616129ab5a0ca64def45649ab522d83fa4a/*"}}

View File

@@ -0,0 +1,98 @@
{
"format": 1,
"restore": {
"E:\\projects\\KioskApp\\GtkSharp\\Source\\Libs\\GLibSharp\\GLibSharp.csproj": {}
},
"projects": {
"E:\\projects\\KioskApp\\GtkSharp\\Source\\Libs\\GLibSharp\\GLibSharp.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "E:\\projects\\KioskApp\\GtkSharp\\Source\\Libs\\GLibSharp\\GLibSharp.csproj",
"projectName": "GLibSharp",
"projectPath": "E:\\projects\\KioskApp\\GtkSharp\\Source\\Libs\\GLibSharp\\GLibSharp.csproj",
"packagesPath": "C:\\Users\\Uther\\.nuget\\packages\\",
"outputPath": "E:\\projects\\KioskApp\\GtkSharp\\Source\\Libs\\GLibSharp\\obj\\",
"projectStyle": "PackageReference",
"crossTargeting": true,
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Uther\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0",
"netstandard2.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {},
"https://nuget.BepInEx.dev/v3/index.json": {},
"https://www.myget.org/f/umod/api/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
},
"netstandard2.0": {
"targetAlias": "netstandard2.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.206/PortableRuntimeIdentifierGraph.json"
},
"netstandard2.0": {
"targetAlias": "netstandard2.0",
"dependencies": {
"NETStandard.Library": {
"suppressParent": "All",
"target": "Package",
"version": "[2.0.3, )",
"autoReferenced": true
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.206\\RuntimeIdentifierGraph.json"
}
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More