Merge pull request #71 from knocte/bindinator
generator and glibsharp changes from bindinator's GSoC work
This commit is contained in:
commit
90e834327e
44 changed files with 2887 additions and 84 deletions
|
@ -56,6 +56,8 @@ namespace GtkSharp.Generation {
|
|||
|
||||
if (!String.IsNullOrEmpty (retval.CountParameterName))
|
||||
retval.CountParameter = parms.GetCountParameter (retval.CountParameterName);
|
||||
if (retval.CountParameterIndex >= 0)
|
||||
retval.CountParameter = parms[retval.CountParameterIndex];
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
@ -68,6 +70,14 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public string WrapperName {
|
||||
get {
|
||||
if (!valid)
|
||||
return String.Empty;
|
||||
return NS + "Sharp." + Name + "Wrapper";
|
||||
}
|
||||
}
|
||||
|
||||
public override string MarshalType {
|
||||
get {
|
||||
if (valid)
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace GtkSharp.Generation {
|
|||
private IDictionary<string, Property> props = new Dictionary<string, Property> ();
|
||||
private IDictionary<string, ObjectField> fields = new Dictionary<string, ObjectField> ();
|
||||
private IDictionary<string, Method> methods = new Dictionary<string, Method> ();
|
||||
private IDictionary<string, Constant> constants = new Dictionary<string, Constant>();
|
||||
protected IList<string> interfaces = new List<string>();
|
||||
protected IList<string> managed_interfaces = new List<string>();
|
||||
protected IList<Ctor> ctors = new List<Ctor>();
|
||||
|
@ -108,6 +109,11 @@ namespace GtkSharp.Generation {
|
|||
ctors.Add (new Ctor (member, this));
|
||||
break;
|
||||
|
||||
case "constant":
|
||||
name = member.GetAttribute ("name");
|
||||
constants.Add (name, new Constant (member));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -156,6 +162,14 @@ namespace GtkSharp.Generation {
|
|||
methods.Remove (method.Name);
|
||||
invalids.Clear ();
|
||||
|
||||
foreach (Constant con in constants.Values) {
|
||||
if (!con.Validate (log))
|
||||
invalids.Add (con);
|
||||
}
|
||||
foreach (Constant con in invalids)
|
||||
constants.Remove (con.Name);
|
||||
invalids.Clear ();
|
||||
|
||||
foreach (Ctor ctor in ctors) {
|
||||
if (!ctor.Validate (log))
|
||||
invalids.Add (ctor);
|
||||
|
@ -199,6 +213,7 @@ namespace GtkSharp.Generation {
|
|||
case "implements":
|
||||
case "constructor":
|
||||
case "disabledefaultconstructor":
|
||||
case "constant":
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -221,6 +236,12 @@ namespace GtkSharp.Generation {
|
|||
field.Generate (gen_info, "\t\t");
|
||||
}
|
||||
|
||||
protected void GenConstants (GenerationInfo gen_info)
|
||||
{
|
||||
foreach (Constant con in constants.Values)
|
||||
con.Generate (gen_info, "\t\t");
|
||||
}
|
||||
|
||||
private void ParseImplements (XmlElement member)
|
||||
{
|
||||
foreach (XmlNode node in member.ChildNodes) {
|
||||
|
|
|
@ -77,9 +77,10 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine (" {");
|
||||
sw.WriteLine ();
|
||||
|
||||
GenConstants (gen_info);
|
||||
GenProperties (gen_info, null);
|
||||
GenMethods (gen_info, null, null);
|
||||
|
||||
|
||||
sw.WriteLine ("#endregion");
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace GtkSharp.Generation {
|
|||
bool show_help = false;
|
||||
string dir = "";
|
||||
string assembly_name = "";
|
||||
string gapidir = "";
|
||||
string glue_filename = "";
|
||||
string glue_includes = "";
|
||||
string gluelib_name = "";
|
||||
|
@ -54,6 +55,8 @@ namespace GtkSharp.Generation {
|
|||
(string v) => { dir = v; } },
|
||||
{ "assembly-name=", "Name of the assembly for which the code is generated.",
|
||||
(string v) => { assembly_name = v; } },
|
||||
{ "gapidir=", "GAPI xml data folder.",
|
||||
(string v) => { gapidir = v; } },
|
||||
{ "glue-filename=", "Filename for the generated C glue code.",
|
||||
(string v) => { glue_filename = v; } },
|
||||
{ "glue-includes=", "Content of #include directive to add in the generated C glue code.",
|
||||
|
@ -101,12 +104,12 @@ namespace GtkSharp.Generation {
|
|||
|
||||
Parser p = new Parser ();
|
||||
foreach (string include in includes) {
|
||||
IGeneratable[] curr_gens = p.Parse (include, schema_name);
|
||||
IGeneratable[] curr_gens = p.Parse (include, schema_name, gapidir);
|
||||
table.AddTypes (curr_gens);
|
||||
}
|
||||
|
||||
foreach (string filename in filenames) {
|
||||
IGeneratable[] curr_gens = p.Parse (filename, schema_name);
|
||||
IGeneratable[] curr_gens = p.Parse (filename, schema_name, gapidir);
|
||||
table.AddTypes (curr_gens);
|
||||
gens.AddRange (curr_gens);
|
||||
}
|
||||
|
|
70
generator/Constant.cs
Normal file
70
generator/Constant.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
|
||||
namespace GtkSharp.Generation
|
||||
{
|
||||
public class Constant
|
||||
{
|
||||
private readonly XmlElement elem;
|
||||
private readonly string name;
|
||||
private readonly string value;
|
||||
private readonly string ctype;
|
||||
|
||||
public Constant (XmlElement elem)
|
||||
{
|
||||
this.elem = elem;
|
||||
this.name = elem.GetAttribute ("name");
|
||||
this.value = elem.GetAttribute ("value");
|
||||
this.ctype = elem.GetAttribute ("ctype");
|
||||
}
|
||||
|
||||
public string Name {
|
||||
get {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
public string ConstType {
|
||||
get {
|
||||
if (IsString)
|
||||
return "string";
|
||||
// gir registers all integer values as gint even for numbers which do not fit into a gint
|
||||
// if the number is too big for an int, try to fit it into a long
|
||||
if (SymbolTable.Table.GetMarshalType (ctype) == "int" && value.Length < 20 && long.Parse (value) > Int32.MaxValue)
|
||||
return "long";
|
||||
return SymbolTable.Table.GetMarshalType (ctype);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsString {
|
||||
get {
|
||||
return (SymbolTable.Table.GetCSType (ctype) == "string");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Validate (LogWriter log)
|
||||
{
|
||||
if (ConstType == String.Empty) {
|
||||
log.Warn ("{0} type is missing or wrong", Name);
|
||||
return false;
|
||||
}
|
||||
if (SymbolTable.Table.GetMarshalType (ctype) == "int" && value.Length >= 20) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Generate (GenerationInfo gen_info, string indent)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
sw.WriteLine ("{0}public const {1} {2} = {3}{4}{5};",
|
||||
indent,
|
||||
ConstType,
|
||||
Name,
|
||||
IsString ? "@\"": String.Empty,
|
||||
value,
|
||||
IsString ? "\"": String.Empty);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,6 +32,8 @@ namespace GtkSharp.Generation {
|
|||
{
|
||||
log.Member = Name;
|
||||
if (!Ignored && !Hidden && CSType == "") {
|
||||
if (Name == "Priv")
|
||||
return false;
|
||||
log.Warn ("field has unknown type: " + CType);
|
||||
Statistics.ThrottledCount++;
|
||||
return false;
|
||||
|
@ -40,21 +42,25 @@ namespace GtkSharp.Generation {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool Readable {
|
||||
internal virtual bool Readable {
|
||||
get {
|
||||
return elem.GetAttribute ("readable") != "false";
|
||||
if (Parser.GetVersion (elem.OwnerDocument.DocumentElement) <= 2)
|
||||
return elem.GetAttribute ("readable") != "false";
|
||||
return elem.HasAttribute ("readable") && elem.GetAttributeAsBoolean ("readable");
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool Writable {
|
||||
internal virtual bool Writable {
|
||||
get {
|
||||
return elem.GetAttribute ("writeable") != "false";
|
||||
if (Parser.GetVersion (elem.OwnerDocument.DocumentElement) <= 2)
|
||||
return elem.GetAttribute ("writeable") != "false";
|
||||
return elem.HasAttribute ("writeable") && elem.GetAttributeAsBoolean ("writeable");
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract string DefaultAccess { get; }
|
||||
|
||||
protected string Access {
|
||||
internal string Access {
|
||||
get {
|
||||
return elem.HasAttribute ("access") ? elem.GetAttribute ("access") : DefaultAccess;
|
||||
}
|
||||
|
@ -152,6 +158,7 @@ namespace GtkSharp.Generation {
|
|||
GenerateImports (gen_info, indent);
|
||||
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
IGeneratable gen = table [CType];
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
string modifiers = elem.GetAttributeAsBoolean ("new_flag") ? "new " : "";
|
||||
bool is_struct = table.IsStruct (CType) || table.IsBoxed (CType);
|
||||
|
@ -172,10 +179,12 @@ namespace GtkSharp.Generation {
|
|||
} else if (Readable && offsetName != null) {
|
||||
sw.WriteLine (indent + "\tget {");
|
||||
sw.WriteLine (indent + "\t\tunsafe {");
|
||||
if (is_struct) {
|
||||
sw.WriteLine (indent + "\t\t\t" + CSType + "* raw_ptr = (" + CSType + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\treturn *raw_ptr;");
|
||||
} else {
|
||||
if (gen is CallbackGen) {
|
||||
sw.WriteLine (indent + "\t\t\tIntPtr* raw_ptr = (IntPtr*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\t {0} del = ({0})Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof({0}));", table.GetMarshalType (CType));
|
||||
sw.WriteLine (indent + "\t\t\treturn " + table.FromNative (ctype, "(del)") + ";");
|
||||
}
|
||||
else {
|
||||
sw.WriteLine (indent + "\t\t\t" + table.GetMarshalType (CType) + "* raw_ptr = (" + table.GetMarshalType (CType) + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\treturn " + table.FromNative (ctype, "(*raw_ptr)") + ";");
|
||||
}
|
||||
|
@ -183,7 +192,6 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine (indent + "\t}");
|
||||
}
|
||||
|
||||
IGeneratable gen = table [CType];
|
||||
string to_native = (gen is IManualMarshaler) ? (gen as IManualMarshaler).AllocNative ("value") : gen.CallByName ("value");
|
||||
|
||||
if (Setter != null) {
|
||||
|
@ -199,10 +207,12 @@ namespace GtkSharp.Generation {
|
|||
} else if (Writable && offsetName != null) {
|
||||
sw.WriteLine (indent + "\tset {");
|
||||
sw.WriteLine (indent + "\t\tunsafe {");
|
||||
if (is_struct) {
|
||||
sw.WriteLine (indent + "\t\t\t" + CSType + "* raw_ptr = (" + CSType + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\t*raw_ptr = value;");
|
||||
} else {
|
||||
if (gen is CallbackGen) {
|
||||
sw.WriteLine (indent + "\t\t\t{0} wrapper = new {0} (value);", ((CallbackGen)gen).WrapperName);
|
||||
sw.WriteLine (indent + "\t\t\tIntPtr* raw_ptr = (IntPtr*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\t*raw_ptr = Marshal.GetFunctionPointerForDelegate (wrapper.NativeDelegate);");
|
||||
}
|
||||
else {
|
||||
sw.WriteLine (indent + "\t\t\t" + table.GetMarshalType (CType) + "* raw_ptr = (" + table.GetMarshalType (CType) + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\t*raw_ptr = " + to_native + ";");
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ sources = \
|
|||
CodeGenerator.cs \
|
||||
ConstFilenameGen.cs \
|
||||
ConstStringGen.cs \
|
||||
Constant.cs \
|
||||
Ctor.cs \
|
||||
DefaultSignalHandler.cs \
|
||||
EnumGen.cs \
|
||||
|
@ -42,6 +43,7 @@ sources = \
|
|||
MethodBase.cs \
|
||||
MethodBody.cs \
|
||||
Method.cs \
|
||||
NativeStructGen.cs \
|
||||
ObjectField.cs \
|
||||
ObjectBase.cs \
|
||||
ObjectGen.cs \
|
||||
|
@ -63,6 +65,7 @@ sources = \
|
|||
StructField.cs \
|
||||
StructGen.cs \
|
||||
SymbolTable.cs \
|
||||
UnionGen.cs \
|
||||
VirtualMethod.cs \
|
||||
VMSignature.cs \
|
||||
XmlElementExtensions.cs
|
||||
|
|
|
@ -84,6 +84,11 @@ namespace GtkSharp.Generation {
|
|||
if (!retval.Validate (log) || !base.Validate (log))
|
||||
return false;
|
||||
|
||||
if (Name == String.Empty || CName == String.Empty) {
|
||||
log.Warn ("Method has no name or cname.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Parameters parms = Parameters;
|
||||
is_get = ((((parms.IsAccessor && retval.IsVoid) || (parms.Count == 0 && !retval.IsVoid)) || (parms.Count == 0 && !retval.IsVoid)) && HasGetterName);
|
||||
is_set = ((parms.IsAccessor || (parms.VisibleCount == 1 && retval.IsVoid)) && HasSetterName);
|
||||
|
@ -207,6 +212,14 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public void GenerateOverloads (StreamWriter sw)
|
||||
{
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\t\tpublic " + retval.CSType + " " + Name + "(" + (Signature != null ? Signature.WithoutOptional () : "") + ") {");
|
||||
sw.WriteLine ("\t\t\t{0}{1} ({2});", !retval.IsVoid ? "return " : String.Empty, Name, Signature.CallWithoutOptionals ());
|
||||
sw.WriteLine ("\t\t}");
|
||||
}
|
||||
|
||||
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
||||
{
|
||||
Method comp = null;
|
||||
|
@ -266,6 +279,9 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
else
|
||||
gen_info.Writer.WriteLine();
|
||||
|
||||
if (Parameters.HasOptional && !(is_get || is_set))
|
||||
GenerateOverloads (gen_info.Writer);
|
||||
|
||||
gen_info.Writer.WriteLine();
|
||||
|
||||
|
|
|
@ -101,17 +101,26 @@ namespace GtkSharp.Generation {
|
|||
if (gen is CallbackGen) {
|
||||
CallbackGen cbgen = gen as CallbackGen;
|
||||
string wrapper = cbgen.GenWrapper(gen_info);
|
||||
|
||||
int closure = i + 1;
|
||||
if (p.Closure >= 0)
|
||||
closure = p.Closure;
|
||||
|
||||
int destroyNotify = i + 2;
|
||||
if (p.DestroyNotify >= 0)
|
||||
destroyNotify = p.DestroyNotify;
|
||||
|
||||
switch (p.Scope) {
|
||||
case "notified":
|
||||
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
||||
sw.WriteLine (indent + "\t\t\tIntPtr {0};", parameters [i + 1].Name);
|
||||
sw.WriteLine (indent + "\t\t\t{0} {1};", parameters [i + 2].CSType, parameters [i + 2].Name);
|
||||
sw.WriteLine (indent + "\t\t\tIntPtr {0};", parameters [closure].Name);
|
||||
sw.WriteLine (indent + "\t\t\t{0} {1};", parameters [destroyNotify].CSType, parameters [destroyNotify].Name);
|
||||
sw.WriteLine (indent + "\t\t\tif ({0} == null) {{", name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = IntPtr.Zero;", parameters [i + 1].Name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = null;", parameters [i + 2].Name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = IntPtr.Zero;", parameters [closure].Name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = null;", parameters [destroyNotify].Name);
|
||||
sw.WriteLine (indent + "\t\t\t} else {");
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = (IntPtr) GCHandle.Alloc ({1}_wrapper);", parameters [i + 1].Name, name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = GLib.DestroyHelper.NotifyHandler;", parameters [i + 2].Name, parameters [i + 2].CSType);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = (IntPtr) GCHandle.Alloc ({1}_wrapper);", parameters [closure].Name, name);
|
||||
sw.WriteLine (indent + "\t\t\t\t{0} = GLib.DestroyHelper.NotifyHandler;", parameters [destroyNotify].Name, parameters [destroyNotify].CSType);
|
||||
sw.WriteLine (indent + "\t\t\t}");
|
||||
break;
|
||||
|
||||
|
|
211
generator/NativeStructGen.cs
Normal file
211
generator/NativeStructGen.cs
Normal file
|
@ -0,0 +1,211 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
|
||||
namespace GtkSharp.Generation
|
||||
{
|
||||
public class NativeStructGen : HandleBase
|
||||
{
|
||||
IList<StructField> fields = new List<StructField> ();
|
||||
|
||||
public NativeStructGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
||||
{
|
||||
foreach (XmlNode node in elem.ChildNodes) {
|
||||
|
||||
if (!(node is XmlElement)) continue;
|
||||
XmlElement member = (XmlElement) node;
|
||||
|
||||
switch (node.Name) {
|
||||
case "field":
|
||||
fields.Add (new StructField (member, this));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!IsNodeNameHandled (node.Name))
|
||||
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string MarshalType {
|
||||
get {
|
||||
return "IntPtr";
|
||||
}
|
||||
}
|
||||
|
||||
public override string AssignToName {
|
||||
get { return "Handle"; }
|
||||
}
|
||||
|
||||
public override string CallByName ()
|
||||
{
|
||||
return "Handle";
|
||||
}
|
||||
|
||||
public override string CallByName (string var)
|
||||
{
|
||||
return String.Format ("{0} == null ? IntPtr.Zero : {0}.{1}", var, "Handle");
|
||||
}
|
||||
|
||||
public override string FromNative (string var, bool owned)
|
||||
{
|
||||
return "new " + QualifiedName + "( " + var + " )";
|
||||
}
|
||||
|
||||
public override void Generate (GenerationInfo gen_info)
|
||||
{
|
||||
bool need_close = false;
|
||||
if (gen_info.Writer == null) {
|
||||
gen_info.Writer = gen_info.OpenStream (Name);
|
||||
need_close = true;
|
||||
}
|
||||
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
sw.WriteLine ("namespace " + NS + " {");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\tusing System;");
|
||||
sw.WriteLine ("\tusing System.Collections;");
|
||||
sw.WriteLine ("\tusing System.Collections.Generic;");
|
||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||
sw.WriteLine ();
|
||||
|
||||
sw.WriteLine ("#region Autogenerated code");
|
||||
if (IsDeprecated)
|
||||
sw.WriteLine ("\t[Obsolete]");
|
||||
string access = IsInternal ? "internal" : "public";
|
||||
sw.WriteLine ("\t" + access + " partial class {0} : {1} IEquatable<{0}> {{", Name, Parent == null ? "GLib.IWrapper," : (Parent.QualifiedName + ","));
|
||||
sw.WriteLine ();
|
||||
|
||||
GenNativeStruct (gen_info);
|
||||
GenNativeAccessor (gen_info);
|
||||
GenFields (gen_info);
|
||||
sw.WriteLine ();
|
||||
GenCtors (gen_info);
|
||||
GenMethods (gen_info, null, this);
|
||||
GenEqualsAndHash (sw);
|
||||
|
||||
if (!need_close)
|
||||
return;
|
||||
|
||||
sw.WriteLine ("#endregion");
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
sw.WriteLine ("}");
|
||||
sw.Close ();
|
||||
gen_info.Writer = null;
|
||||
}
|
||||
|
||||
private void GenNativeStruct (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
sw.WriteLine ("\t\t[StructLayout(LayoutKind.Sequential)]");
|
||||
sw.WriteLine ("\t\tprivate partial struct NativeStruct {");
|
||||
foreach (StructField field in fields) {
|
||||
field.Generate (gen_info, "\t\t\t");
|
||||
}
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
}
|
||||
|
||||
private void GenNativeAccessor (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
sw.WriteLine ("\t\tNativeStruct Native {{", QualifiedName);
|
||||
sw.WriteLine ("\t\t\tget { return (NativeStruct) Marshal.PtrToStructure (Handle, typeof (NativeStruct)); }");
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
}
|
||||
|
||||
protected override void GenCtors (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
if (Parent == null) {
|
||||
sw.WriteLine ("\t\tpublic {0} (IntPtr raw)", Name);
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\tthis.Handle = raw;");
|
||||
sw.WriteLine ("\t\t}");
|
||||
}
|
||||
else
|
||||
sw.Write ("\t\tpublic {0} (IntPtr raw) : base (raw) {{}}", Name);
|
||||
|
||||
sw.WriteLine ();
|
||||
|
||||
base.GenCtors (gen_info);
|
||||
}
|
||||
|
||||
protected new void GenFields (GenerationInfo gen_info)
|
||||
{
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
sw.WriteLine ("\t\tprivate IntPtr Raw;");
|
||||
|
||||
sw.WriteLine ("\t\tpublic IntPtr Handle {");
|
||||
sw.WriteLine ("\t\t\tget { return Raw; }");
|
||||
sw.WriteLine ("\t\t\tset { Raw = value; }");
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
|
||||
foreach (StructField field in fields) {
|
||||
if (!field.Visible)
|
||||
continue;
|
||||
sw.WriteLine ("\t\tpublic {0} {1} {{", SymbolTable.Table.GetCSType (field.CType), field.StudlyName);
|
||||
sw.WriteLine ("\t\t\tget {{ return Native.{0}; }}", field.StudlyName);
|
||||
if (!(SymbolTable.Table [field.CType] is CallbackGen))
|
||||
sw.WriteLine ("\t\t\tset {{ NativeStruct native = Native; native.{0} = value; Marshal.StructureToPtr (native, this.Handle, false); }}", field.StudlyName);
|
||||
sw.WriteLine ("\t\t}");
|
||||
}
|
||||
}
|
||||
|
||||
protected void GenEqualsAndHash (StreamWriter sw)
|
||||
{
|
||||
int bitfields = 0;
|
||||
bool need_field = true;
|
||||
StringBuilder hashcode = new StringBuilder ();
|
||||
StringBuilder equals = new StringBuilder ();
|
||||
|
||||
sw.WriteLine ("\t\tpublic bool Equals ({0} other)", Name);
|
||||
sw.WriteLine ("\t\t{");
|
||||
hashcode.Append ("this.GetType().FullName.GetHashCode()");
|
||||
equals.Append ("true");
|
||||
|
||||
foreach (StructField field in fields) {
|
||||
if (field.IsPadding || !field.Visible || field.IsBitfield)
|
||||
continue;
|
||||
|
||||
need_field = true;
|
||||
equals.Append (" && ");
|
||||
equals.Append (field.EqualityName);
|
||||
equals.Append (".Equals (other.");
|
||||
equals.Append (field.EqualityName);
|
||||
equals.Append (")");
|
||||
hashcode.Append (" ^ ");
|
||||
hashcode.Append (field.EqualityName);
|
||||
hashcode.Append (".GetHashCode ()");
|
||||
}
|
||||
sw.WriteLine ("\t\t\treturn {0};", equals.ToString ());
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\t\tpublic override bool Equals (object other)");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\treturn other is {0} && Equals (({0}) other);", Name);
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
if (Elem.GetAttribute ("nohash") == "true")
|
||||
return;
|
||||
sw.WriteLine ("\t\tpublic override int GetHashCode ()");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\treturn {0};", hashcode.ToString ());
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ namespace GtkSharp.Generation {
|
|||
ctype = "const-" + CType;
|
||||
}
|
||||
|
||||
protected override bool Writable {
|
||||
internal override bool Writable {
|
||||
get {
|
||||
return elem.GetAttributeAsBoolean ("writeable");
|
||||
}
|
||||
|
|
|
@ -195,9 +195,10 @@ namespace GtkSharp.Generation {
|
|||
GenSignals (gen_info, null);
|
||||
}
|
||||
|
||||
GenConstants (gen_info);
|
||||
GenClassMembers (gen_info, cs_parent);
|
||||
GenMethods (gen_info, null, null);
|
||||
|
||||
|
||||
if (interfaces.Count != 0) {
|
||||
var all_methods = new Dictionary<string, Method> ();
|
||||
foreach (Method m in Methods.Values) {
|
||||
|
@ -260,8 +261,9 @@ namespace GtkSharp.Generation {
|
|||
{
|
||||
if (!Elem.HasAttribute("parent"))
|
||||
return;
|
||||
string defaultconstructoraccess = Elem.HasAttribute ("defaultconstructoraccess") ? Elem.GetAttribute ("defaultconstructoraccess") : "public";
|
||||
|
||||
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||
gen_info.Writer.WriteLine ("\t\t"+ defaultconstructoraccess + " " + Name + " (IntPtr raw) : base(raw) {}");
|
||||
if (ctors.Count == 0 && !DisableVoidCtor) {
|
||||
gen_info.Writer.WriteLine();
|
||||
gen_info.Writer.WriteLine("\t\tprotected " + Name + "() : base(IntPtr.Zero)");
|
||||
|
|
|
@ -79,7 +79,8 @@ namespace GtkSharp.Generation {
|
|||
|
||||
sw.WriteLine (" {");
|
||||
sw.WriteLine ();
|
||||
|
||||
|
||||
GenConstants (gen_info);
|
||||
GenFields (gen_info);
|
||||
GenMethods (gen_info, null, null);
|
||||
GenCtors (gen_info);
|
||||
|
|
|
@ -90,6 +90,12 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
internal bool IsOptional {
|
||||
get {
|
||||
return elem.GetAttributeAsBoolean ("allow-none");
|
||||
}
|
||||
}
|
||||
|
||||
bool is_count;
|
||||
bool is_count_set;
|
||||
public bool IsCount {
|
||||
|
@ -236,6 +242,30 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
int closure = -1;
|
||||
public int Closure {
|
||||
get {
|
||||
if(closure == -1 && elem.HasAttribute ("closure"))
|
||||
closure = int.Parse(elem.GetAttribute ("closure"));
|
||||
return closure;
|
||||
}
|
||||
set {
|
||||
closure = value;
|
||||
}
|
||||
}
|
||||
|
||||
int destroynotify = -1;
|
||||
public int DestroyNotify {
|
||||
get {
|
||||
if (destroynotify == -1 && elem.HasAttribute ("destroy"))
|
||||
destroynotify = int.Parse (elem.GetAttribute ("destroy"));
|
||||
return destroynotify;
|
||||
}
|
||||
set {
|
||||
destroynotify = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string[] Prepare {
|
||||
get {
|
||||
IGeneratable gen = Generatable;
|
||||
|
|
|
@ -49,6 +49,18 @@ namespace GtkSharp.Generation {
|
|||
get { return param_list.Count; }
|
||||
}
|
||||
|
||||
// gapi assumes GError** parameters to be error parameters in version 1 and 2
|
||||
private bool throws = false;
|
||||
public bool Throws {
|
||||
get {
|
||||
if (Parser.GetVersion (elem.OwnerDocument.DocumentElement) <= 2)
|
||||
return true;
|
||||
if (!throws && elem.HasAttribute ("throws"))
|
||||
throws = elem.GetAttributeAsBoolean ("throws");
|
||||
return throws;
|
||||
}
|
||||
}
|
||||
|
||||
public int VisibleCount {
|
||||
get {
|
||||
int visible = 0;
|
||||
|
@ -76,20 +88,28 @@ namespace GtkSharp.Generation {
|
|||
if (p.IsCount)
|
||||
return true;
|
||||
|
||||
if (p.CType == "GError**")
|
||||
if (p.CType == "GError**" && Throws)
|
||||
return true;
|
||||
|
||||
if (HasCB || HideData) {
|
||||
if (p.IsUserData && (idx == Count - 1))
|
||||
return true;
|
||||
if (p.IsUserData && (idx == Count - 2) && this [Count - 1] is ErrorParameter)
|
||||
return true;
|
||||
if (p.IsUserData && idx > 0 &&
|
||||
this [idx - 1].Generatable is CallbackGen)
|
||||
return true;
|
||||
if (p.IsDestroyNotify && (idx == Count - 1) &&
|
||||
this [idx - 1].IsUserData)
|
||||
return true;
|
||||
|
||||
if (Parser.GetVersion (elem.OwnerDocument.DocumentElement) >= 3) {
|
||||
foreach (Parameter param in param_list) {
|
||||
if (param.Closure == idx)
|
||||
return true;
|
||||
if (param.DestroyNotify == idx)
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (p.IsUserData && (idx == Count - 1))
|
||||
return true;
|
||||
if (p.IsUserData && (idx == Count - 2) && this [Count - 1] is ErrorParameter)
|
||||
return true;
|
||||
if (p.IsUserData && idx > 0 && this [idx - 1].Generatable is CallbackGen)
|
||||
return true;
|
||||
if (p.IsDestroyNotify && (idx == Count - 1) && this [idx - 1].IsUserData)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -122,6 +142,11 @@ namespace GtkSharp.Generation {
|
|||
set { is_static = value; }
|
||||
}
|
||||
|
||||
bool has_optional;
|
||||
internal bool HasOptional {
|
||||
get { return has_optional;}
|
||||
}
|
||||
|
||||
public Parameter GetCountParameter (string param_name)
|
||||
{
|
||||
foreach (Parameter p in this)
|
||||
|
@ -178,6 +203,9 @@ namespace GtkSharp.Generation {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (p.IsOptional && p.PassAs == String.Empty)
|
||||
has_optional = true;
|
||||
|
||||
IGeneratable gen = p.Generatable;
|
||||
|
||||
if (p.IsArray) {
|
||||
|
@ -204,7 +232,7 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (p.CType == "GError**")
|
||||
} else if (p.CType == "GError**" && Throws)
|
||||
p = new ErrorParameter (parm);
|
||||
else if (gen is StructBase || gen is ByRefGen) {
|
||||
p = new StructParameter (parm);
|
||||
|
@ -214,7 +242,8 @@ namespace GtkSharp.Generation {
|
|||
param_list.Add (p);
|
||||
}
|
||||
|
||||
if (has_cb && Count > 2 && this [Count - 3].Generatable is CallbackGen && this [Count - 2].IsUserData && this [Count - 1].IsDestroyNotify)
|
||||
if (Parser.GetVersion (elem.OwnerDocument.DocumentElement) < 3 &&
|
||||
has_cb && Count > 2 && this [Count - 3].Generatable is CallbackGen && this [Count - 2].IsUserData && this [Count - 1].IsDestroyNotify)
|
||||
this [Count - 3].Scope = "notified";
|
||||
|
||||
valid = true;
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace GtkSharp.Generation {
|
|||
using System.Xml.Schema;
|
||||
|
||||
public class Parser {
|
||||
const int curr_parser_version = 2;
|
||||
const int curr_parser_version = 3;
|
||||
|
||||
private XmlDocument Load (string filename, string schema_file)
|
||||
{
|
||||
|
@ -77,6 +77,11 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
|
||||
public IGeneratable[] Parse (string filename, string schema_file)
|
||||
{
|
||||
return Parse (filename, schema_file, String.Empty);
|
||||
}
|
||||
|
||||
public IGeneratable[] Parse (string filename, string schema_file, string gapidir)
|
||||
{
|
||||
XmlDocument doc = Load (filename, schema_file);
|
||||
if (doc == null)
|
||||
|
@ -111,6 +116,21 @@ namespace GtkSharp.Generation {
|
|||
continue;
|
||||
|
||||
switch (child.Name) {
|
||||
case "include":
|
||||
string xmlpath;
|
||||
|
||||
if (File.Exists (Path.Combine (gapidir, elem.GetAttribute ("xml"))))
|
||||
xmlpath = Path.Combine (gapidir, elem.GetAttribute ("xml"));
|
||||
else if (File.Exists (elem.GetAttribute ("xml")))
|
||||
xmlpath = elem.GetAttribute ("xml");
|
||||
else {
|
||||
Console.WriteLine ("Parser: Could not find include " + elem.GetAttribute ("xml"));
|
||||
break;
|
||||
}
|
||||
|
||||
IGeneratable[] curr_gens = Parse (xmlpath);
|
||||
SymbolTable.Table.AddTypes (curr_gens);
|
||||
break;
|
||||
case "namespace":
|
||||
gens.AddRange (ParseNamespace (elem));
|
||||
break;
|
||||
|
@ -140,6 +160,7 @@ namespace GtkSharp.Generation {
|
|||
continue;
|
||||
|
||||
bool is_opaque = elem.GetAttributeAsBoolean ("opaque");
|
||||
bool is_native_struct = elem.GetAttributeAsBoolean ("native");
|
||||
|
||||
switch (def.Name) {
|
||||
case "alias":
|
||||
|
@ -171,9 +192,14 @@ namespace GtkSharp.Generation {
|
|||
case "class":
|
||||
result.Add (new ClassGen (ns, elem));
|
||||
break;
|
||||
case "union":
|
||||
result.Add (new UnionGen (ns, elem));
|
||||
break;
|
||||
case "struct":
|
||||
if (is_opaque) {
|
||||
result.Add (new OpaqueGen (ns, elem));
|
||||
} else if (is_native_struct) {
|
||||
result.Add (new NativeStructGen (ns, elem));
|
||||
} else {
|
||||
result.Add (new StructGen (ns, elem));
|
||||
}
|
||||
|
@ -187,6 +213,12 @@ namespace GtkSharp.Generation {
|
|||
return result;
|
||||
}
|
||||
|
||||
internal static int GetVersion (XmlElement document_element)
|
||||
{
|
||||
XmlElement root = document_element;
|
||||
return root.HasAttribute ("parser_version") ? int.Parse (root.GetAttribute ("parser_version")) : 1;
|
||||
}
|
||||
|
||||
private IGeneratable ParseSymbol (XmlElement symbol)
|
||||
{
|
||||
string type = symbol.GetAttribute ("type");
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace GtkSharp.Generation {
|
|||
bool elements_owned;
|
||||
bool owned;
|
||||
string array_length_param = String.Empty;
|
||||
int array_length_param_index = -1;
|
||||
string ctype = String.Empty;
|
||||
string default_value = String.Empty;
|
||||
string element_ctype = String.Empty;
|
||||
|
@ -43,6 +44,8 @@ namespace GtkSharp.Generation {
|
|||
is_null_term = elem.GetAttributeAsBoolean ("null_term_array");
|
||||
is_array = elem.GetAttributeAsBoolean ("array") || elem.HasAttribute ("array_length_param");
|
||||
array_length_param = elem.GetAttribute ("array_length_param");
|
||||
if (elem.HasAttribute ("array_length_param_length"))
|
||||
array_length_param_index = int.Parse (elem.GetAttribute ("array_length_param_index"));
|
||||
elements_owned = elem.GetAttributeAsBoolean ("elements_owned");
|
||||
owned = elem.GetAttributeAsBoolean ("owned");
|
||||
ctype = elem.GetAttribute("type");
|
||||
|
@ -60,6 +63,10 @@ namespace GtkSharp.Generation {
|
|||
get { return array_length_param; }
|
||||
}
|
||||
|
||||
public int CountParameterIndex {
|
||||
get { return array_length_param_index; }
|
||||
}
|
||||
|
||||
public string CType {
|
||||
get {
|
||||
return ctype;
|
||||
|
@ -126,7 +133,9 @@ namespace GtkSharp.Generation {
|
|||
get {
|
||||
if (IGen == null)
|
||||
return String.Empty;
|
||||
return IGen.MarshalType + (is_array || is_null_term ? "[]" : String.Empty);
|
||||
if (is_array || is_null_term)
|
||||
return "IntPtr";
|
||||
return IGen.MarshalType;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +169,7 @@ namespace GtkSharp.Generation {
|
|||
string args = ", typeof (" + ElementType + "), " + (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
|
||||
var = "new " + IGen.QualifiedName + "(" + var + args + ")";
|
||||
} else if (is_null_term)
|
||||
return String.Format ("GLib.Marshaller.StringArrayToNullTermPointer ({0})", var);
|
||||
return String.Format ("GLib.Marshaller.StringArrayToNullTermStrvPointer ({0})", var);
|
||||
else if (is_array)
|
||||
return String.Format ("GLib.Marshaller.ArrayToArrayPtr ({0})", var);
|
||||
|
||||
|
|
|
@ -118,6 +118,48 @@ namespace GtkSharp.Generation {
|
|||
return String.Join (", ", result);
|
||||
}
|
||||
}
|
||||
|
||||
public string WithoutOptional ()
|
||||
{
|
||||
if (parms.Count == 0)
|
||||
return String.Empty;
|
||||
|
||||
var result = new string [parms.Count];
|
||||
int i = 0;
|
||||
|
||||
foreach (Parameter p in parms) {
|
||||
if (p.IsOptional && p.PassAs == String.Empty)
|
||||
continue;
|
||||
result [i] = p.PassAs != String.Empty ? p.PassAs + " " : String.Empty;
|
||||
result [i++] += p.CSType + " " + p.Name;
|
||||
}
|
||||
|
||||
return String.Join (", ", result, 0, i);
|
||||
}
|
||||
|
||||
public string CallWithoutOptionals ()
|
||||
{
|
||||
if (parms.Count == 0)
|
||||
return String.Empty;
|
||||
|
||||
var result = new string [parms.Count];
|
||||
int i = 0;
|
||||
|
||||
foreach (Parameter p in parms) {
|
||||
|
||||
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
||||
if (p.IsOptional && p.PassAs == String.Empty) {
|
||||
if (p.IsArray)
|
||||
result [i++] += "null";
|
||||
else
|
||||
result [i++] += p.Generatable.DefaultValue;
|
||||
}
|
||||
else
|
||||
result [i++] += p.Name;
|
||||
}
|
||||
|
||||
return String.Join (", ", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
// GtkSharp.Generation.StructBase.cs - The Structure/Boxed Base Class.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
// Authors:
|
||||
// Mike Kestner <mkestner@speakeasy.net>
|
||||
// Stephan Sundermann <stephansundermann@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2001-2003 Mike Kestner
|
||||
// Copyright (c) 2013 Stephan Sundermann
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
|
@ -107,36 +110,53 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public virtual bool Union {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void GenEqualsAndHash (StreamWriter sw)
|
||||
{
|
||||
int bitfields = 0;
|
||||
bool need_field = true;
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
StringBuilder hashcode = new StringBuilder ();
|
||||
StringBuilder equals = new StringBuilder ();
|
||||
|
||||
sw.WriteLine ("\t\tpublic bool Equals ({0} other)", Name);
|
||||
sw.WriteLine ("\t\t{");
|
||||
hashcode.Append ("this.GetType ().FullName.GetHashCode ()");
|
||||
equals.Append ("true");
|
||||
|
||||
foreach (StructField field in fields) {
|
||||
if (field.IsPadding)
|
||||
continue;
|
||||
if (field.IsBitfield) {
|
||||
if (need_field) {
|
||||
sw.WriteLine ("\t\tif (!_bitfield{0}.Equals (other._bitfield{0})) return false;", bitfields);
|
||||
if (sb.Length > 0)
|
||||
sb.Append (" ^ ");
|
||||
sb.Append ("_bitfield");
|
||||
sb.Append (bitfields++);
|
||||
sb.Append (".GetHashCode ()");
|
||||
equals.Append (" && _bitfield");
|
||||
equals.Append (bitfields);
|
||||
equals.Append (".Equals (other._bitfield");
|
||||
equals.Append (bitfields);
|
||||
equals.Append (")");
|
||||
hashcode.Append (" ^ ");
|
||||
hashcode.Append ("_bitfield");
|
||||
hashcode.Append (bitfields++);
|
||||
hashcode.Append (".GetHashCode ()");
|
||||
need_field = false;
|
||||
}
|
||||
} else {
|
||||
need_field = true;
|
||||
sw.WriteLine ("\t\t\tif (!{0}.Equals (other.{0})) return false;", field.EqualityName);
|
||||
if (sb.Length > 0)
|
||||
sb.Append (" ^ ");
|
||||
sb.Append (field.EqualityName);
|
||||
sb.Append (".GetHashCode ()");
|
||||
equals.Append (" && ");
|
||||
equals.Append (field.EqualityName);
|
||||
equals.Append (".Equals (other.");
|
||||
equals.Append (field.EqualityName);
|
||||
equals.Append (")");
|
||||
hashcode.Append (" ^ ");
|
||||
hashcode.Append (field.EqualityName);
|
||||
hashcode.Append (".GetHashCode ()");
|
||||
}
|
||||
}
|
||||
sw.WriteLine ("\t\t\treturn true;");
|
||||
sw.WriteLine ("\t\t\treturn {0};", equals.ToString ());
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\t\tpublic override bool Equals (object other)");
|
||||
|
@ -148,7 +168,7 @@ namespace GtkSharp.Generation {
|
|||
return;
|
||||
sw.WriteLine ("\t\tpublic override int GetHashCode ()");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\treturn {0};", sb.ToString ());
|
||||
sw.WriteLine ("\t\t\treturn {0};", hashcode.ToString ());
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
|
||||
|
@ -158,12 +178,13 @@ namespace GtkSharp.Generation {
|
|||
{
|
||||
int bitfields = 0;
|
||||
bool need_field = true;
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
foreach (StructField field in fields) {
|
||||
if (Union)
|
||||
sw.WriteLine ("\t\t[FieldOffset(0)]");
|
||||
if (field.IsBitfield) {
|
||||
if (need_field) {
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
|
||||
sw.WriteLine ("\t\tprivate uint _bitfield{0};\n", bitfields++);
|
||||
need_field = false;
|
||||
}
|
||||
|
@ -207,7 +228,10 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("#region Autogenerated code");
|
||||
if (IsDeprecated)
|
||||
sw.WriteLine ("\t[Obsolete]");
|
||||
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
||||
if (Union)
|
||||
sw.WriteLine ("\t[StructLayout(LayoutKind.Explicit)]");
|
||||
else
|
||||
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
||||
string access = IsInternal ? "internal" : "public";
|
||||
sw.WriteLine ("\t" + access + " partial struct {0} : IEquatable<{0}> {{", Name);
|
||||
sw.WriteLine ();
|
||||
|
|
|
@ -58,6 +58,10 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
bool IsNullTermArray {
|
||||
get { return elem.GetAttributeAsBoolean ("null_term_array"); }
|
||||
}
|
||||
|
||||
public new string CSType {
|
||||
get {
|
||||
string type = base.CSType;
|
||||
|
@ -70,6 +74,13 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
bool visible = false;
|
||||
internal bool Visible {
|
||||
get {
|
||||
return visible;
|
||||
}
|
||||
}
|
||||
|
||||
public string EqualityName {
|
||||
get {
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
|
@ -80,7 +91,7 @@ namespace GtkSharp.Generation {
|
|||
return StudlyName;
|
||||
else if (IsBitfield)
|
||||
return Name;
|
||||
else if (IsPointer && (gen is StructGen || gen is BoxedGen))
|
||||
else if (IsPointer && (gen is StructGen || gen is BoxedGen || gen is UnionGen))
|
||||
return Access != "private" ? wrapped_name : Name;
|
||||
else if (IsPointer && CSType != "string")
|
||||
return Name;
|
||||
|
@ -89,7 +100,7 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
bool IsPadding {
|
||||
public bool IsPadding {
|
||||
get {
|
||||
return (CName.StartsWith ("dummy") || CName.StartsWith ("padding"));
|
||||
}
|
||||
|
@ -127,6 +138,8 @@ namespace GtkSharp.Generation {
|
|||
if (Hidden)
|
||||
return;
|
||||
|
||||
visible = Access != "private";
|
||||
|
||||
StreamWriter sw = gen_info.Writer;
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
|
||||
|
@ -134,9 +147,21 @@ namespace GtkSharp.Generation {
|
|||
string wrapped_name = SymbolTable.Table.MangleName (CName);
|
||||
IGeneratable gen = table [CType];
|
||||
|
||||
if (IsArray) {
|
||||
if (IsArray && !IsNullTermArray) {
|
||||
sw.WriteLine (indent + "[MarshalAs (UnmanagedType.ByValArray, SizeConst=" + ArrayLength + ")]");
|
||||
sw.WriteLine (indent + "{0} {1} {2};", Access, CSType, StudlyName);
|
||||
} else if (IsArray && IsNullTermArray) {
|
||||
sw.WriteLine (indent + "private {0} {1};", "IntPtr", StudlyName+ "Ptr");
|
||||
if ((Readable || Writable) && Access == "public") {
|
||||
sw.WriteLine (indent + "public {0} {1} {{", CSType, StudlyName);
|
||||
if (Readable)
|
||||
sw.WriteLine (indent + "\tget {{ return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<{0}> ({1}); }}",
|
||||
base.CSType, StudlyName + "Ptr");
|
||||
if (Writable)
|
||||
sw.WriteLine (indent + "\tset {{ {0} = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<{1}> (value); }}",
|
||||
StudlyName + "Ptr", base.CSType);
|
||||
sw.WriteLine (indent + "}");
|
||||
}
|
||||
} else if (IsBitfield) {
|
||||
base.Generate (gen_info, indent);
|
||||
} else if (gen is IAccessor) {
|
||||
|
@ -148,7 +173,7 @@ namespace GtkSharp.Generation {
|
|||
acc.WriteAccessors (sw, indent + "\t", Name);
|
||||
sw.WriteLine (indent + "}");
|
||||
}
|
||||
} else if (IsPointer && (gen is StructGen || gen is BoxedGen)) {
|
||||
} else if (IsPointer && (gen is StructGen || gen is BoxedGen || gen is UnionGen)) {
|
||||
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
|
||||
sw.WriteLine ();
|
||||
if (Access != "private") {
|
||||
|
@ -158,6 +183,7 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
} else if (IsPointer && CSType != "string") {
|
||||
// FIXME: probably some fields here which should be visible.
|
||||
visible = false;
|
||||
sw.WriteLine (indent + "private {0} {1};", CSType, Name);
|
||||
} else {
|
||||
sw.WriteLine (indent + "{0} {1} {2};", Access, CSType, Access == "public" ? StudlyName : Name);
|
||||
|
|
|
@ -69,6 +69,7 @@ namespace GtkSharp.Generation {
|
|||
AddType (new SimpleGen ("guint32", "uint", "0"));
|
||||
AddType (new SimpleGen ("gint64", "long", "0"));
|
||||
AddType (new SimpleGen ("guint64", "ulong", "0"));
|
||||
AddType (new SimpleGen ("unsigned long long", "ulong", "0"));
|
||||
AddType (new SimpleGen ("long long", "long", "0"));
|
||||
AddType (new SimpleGen ("gfloat", "float", "0.0"));
|
||||
AddType (new SimpleGen ("float", "float", "0.0"));
|
||||
|
@ -126,12 +127,21 @@ namespace GtkSharp.Generation {
|
|||
AddType (new ManualGen ("GVariant", "GLib.Variant"));
|
||||
AddType (new ManualGen ("GVariantType", "GLib.VariantType"));
|
||||
AddType (new ManualGen ("GValueArray", "GLib.ValueArray"));
|
||||
AddType (new ManualGen ("GMutex", "GLib.Mutex"));
|
||||
AddType (new ManualGen ("GRecMutex", "GLib.RecMutex"));
|
||||
AddType (new ManualGen ("GCond", "GLib.Cond"));
|
||||
AddType (new ManualGen ("GDateTime", "GLib.DateTime"));
|
||||
AddType (new ManualGen ("GDate", "GLib.Date"));
|
||||
AddType (new ManualGen ("GSource", "GLib.Source"));
|
||||
AddType (new ManualGen ("GMainContext", "GLib.MainContext"));
|
||||
AddType (new SimpleGen ("GPollFD", "GLib.PollFD", "GLib.PollFD.Zero"));
|
||||
AddType (new MarshalGen ("gunichar", "char", "uint", "GLib.Marshaller.CharToGUnichar ({0})", "GLib.Marshaller.GUnicharToChar ({0})"));
|
||||
AddType (new MarshalGen ("time_t", "System.DateTime", "IntPtr", "GLib.Marshaller.DateTimeTotime_t ({0})", "GLib.Marshaller.time_tToDateTime ({0})"));
|
||||
AddType (new MarshalGen ("GString", "string", "IntPtr", "new GLib.GString ({0}).Handle", "GLib.GString.PtrToString ({0})"));
|
||||
AddType (new MarshalGen ("GType", "GLib.GType", "IntPtr", "{0}.Val", "new GLib.GType({0})", "GLib.GType.None"));
|
||||
AddType (new ByRefGen ("GValue", "GLib.Value"));
|
||||
AddType (new SimpleGen ("GDestroyNotify", "GLib.DestroyNotify", "null"));
|
||||
AddType (new SimpleGen ("GThread", "GLib.Thread", "null"));
|
||||
|
||||
// FIXME: These ought to be handled properly.
|
||||
AddType (new SimpleGen ("GC", "IntPtr", "IntPtr.Zero"));
|
||||
|
@ -289,6 +299,13 @@ namespace GtkSharp.Generation {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsUnion (string c_type)
|
||||
{
|
||||
if (this[c_type] is UnionGen)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsEnum(string c_type)
|
||||
{
|
||||
|
|
18
generator/UnionGen.cs
Normal file
18
generator/UnionGen.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
using System.Xml;
|
||||
|
||||
namespace GtkSharp.Generation
|
||||
{
|
||||
public class UnionGen : StructBase {
|
||||
|
||||
public UnionGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Union {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -91,6 +91,9 @@
|
|||
<Compile Include="Parameter.cs" />
|
||||
<Compile Include="ArrayParameter.cs" />
|
||||
<Compile Include="Options.cs" />
|
||||
<Compile Include="Constant.cs" />
|
||||
<Compile Include="UnionGen.cs" />
|
||||
<Compile Include="NativeStructGen.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="DESIGN" />
|
||||
|
@ -100,4 +103,4 @@
|
|||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
62
glib/Cond.cs
Normal file
62
glib/Cond.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
// 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 {
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_cond_broadcast(IntPtr raw);
|
||||
|
||||
public void Broadcast() {
|
||||
g_cond_broadcast(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_cond_clear(IntPtr raw);
|
||||
|
||||
public void Clear() {
|
||||
g_cond_clear(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_cond_init(IntPtr raw);
|
||||
|
||||
public void Init() {
|
||||
g_cond_init(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_cond_signal(IntPtr raw);
|
||||
|
||||
public void Signal() {
|
||||
g_cond_signal(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_cond_wait(IntPtr raw, IntPtr mutex);
|
||||
|
||||
public void Wait(GLib.Mutex mutex) {
|
||||
g_cond_wait(Handle, mutex == null ? IntPtr.Zero : mutex.Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_cond_wait_until(IntPtr raw, IntPtr mutex, long end_time);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
478
glib/Date.cs
Normal file
478
glib/Date.cs
Normal file
|
@ -0,0 +1,478 @@
|
|||
// 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 {
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr 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;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_add_days(IntPtr raw, uint n_days);
|
||||
|
||||
public void AddDays(uint n_days) {
|
||||
g_date_add_days(Handle, n_days);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_add_months(IntPtr raw, uint n_months);
|
||||
|
||||
public void AddMonths(uint n_months) {
|
||||
g_date_add_months(Handle, n_months);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_add_years(IntPtr raw, uint n_years);
|
||||
|
||||
public void AddYears(uint n_years) {
|
||||
g_date_add_years(Handle, n_years);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_clamp(IntPtr raw, IntPtr min_date, IntPtr max_date);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_clear(IntPtr raw, uint n_dates);
|
||||
|
||||
public void Clear(uint n_dates) {
|
||||
g_date_clear(Handle, n_dates);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_compare(IntPtr raw, IntPtr rhs);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_days_between(IntPtr raw, IntPtr date2);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern byte g_date_get_day(IntPtr raw);
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_day(IntPtr raw, byte 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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern uint g_date_get_day_of_year(IntPtr raw);
|
||||
|
||||
public uint DayOfYear {
|
||||
get {
|
||||
uint raw_ret = g_date_get_day_of_year(Handle);
|
||||
uint ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern uint g_date_get_iso8601_week_of_year(IntPtr raw);
|
||||
|
||||
public uint Iso8601WeekOfYear {
|
||||
get {
|
||||
uint raw_ret = g_date_get_iso8601_week_of_year(Handle);
|
||||
uint ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern uint g_date_get_julian(IntPtr raw);
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_julian(IntPtr raw, uint julian_date);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern uint g_date_get_monday_week_of_year(IntPtr raw);
|
||||
|
||||
public uint MondayWeekOfYear {
|
||||
get {
|
||||
uint raw_ret = g_date_get_monday_week_of_year(Handle);
|
||||
uint ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_get_month(IntPtr raw);
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_month(IntPtr raw, int 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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern uint g_date_get_sunday_week_of_year(IntPtr raw);
|
||||
|
||||
public uint SundayWeekOfYear {
|
||||
get {
|
||||
uint raw_ret = g_date_get_sunday_week_of_year(Handle);
|
||||
uint ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_get_weekday(IntPtr raw);
|
||||
|
||||
public int Weekday {
|
||||
get {
|
||||
int raw_ret = g_date_get_weekday(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern ushort g_date_get_year(IntPtr raw);
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_year(IntPtr raw, ushort 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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_is_first_of_month(IntPtr raw);
|
||||
|
||||
public bool IsFirstOfMonth {
|
||||
get {
|
||||
bool raw_ret = g_date_is_first_of_month(Handle);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_is_last_of_month(IntPtr raw);
|
||||
|
||||
public bool IsLastOfMonth {
|
||||
get {
|
||||
bool raw_ret = g_date_is_last_of_month(Handle);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_order(IntPtr raw, IntPtr date2);
|
||||
|
||||
public void Order(GLib.Date date2) {
|
||||
g_date_order(Handle, date2 == null ? IntPtr.Zero : date2.Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_dmy(IntPtr raw, byte day, int month, ushort y);
|
||||
|
||||
public void SetDmy(byte day, int month, ushort y) {
|
||||
g_date_set_dmy(Handle, day, month, y);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_parse(IntPtr raw, IntPtr str);
|
||||
|
||||
public string Parse {
|
||||
set {
|
||||
IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
|
||||
g_date_set_parse(Handle, native_value);
|
||||
GLib.Marshaller.Free (native_value);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_time(IntPtr raw, int time_);
|
||||
|
||||
[Obsolete]
|
||||
public int Time {
|
||||
set {
|
||||
g_date_set_time(Handle, value);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_time_t(IntPtr raw, IntPtr timet);
|
||||
|
||||
public long TimeT {
|
||||
set {
|
||||
g_date_set_time_t(Handle, new IntPtr (value));
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_set_time_val(IntPtr raw, IntPtr value);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_subtract_days(IntPtr raw, uint n_days);
|
||||
|
||||
public void SubtractDays(uint n_days) {
|
||||
g_date_subtract_days(Handle, n_days);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_subtract_months(IntPtr raw, uint n_months);
|
||||
|
||||
public void SubtractMonths(uint n_months) {
|
||||
g_date_subtract_months(Handle, n_months);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_subtract_years(IntPtr raw, uint n_years);
|
||||
|
||||
public void SubtractYears(uint n_years) {
|
||||
g_date_subtract_years(Handle, n_years);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_to_struct_tm(IntPtr raw, IntPtr tm);
|
||||
|
||||
public void ToStructTm(IntPtr tm) {
|
||||
g_date_to_struct_tm(Handle, tm);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_valid(IntPtr raw);
|
||||
|
||||
public bool Valid() {
|
||||
bool raw_ret = g_date_valid(Handle);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern byte g_date_get_days_in_month(int month, ushort year);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern byte g_date_get_monday_weeks_in_year(ushort year);
|
||||
|
||||
public static byte GetMondayWeeksInYear(ushort year) {
|
||||
byte raw_ret = g_date_get_monday_weeks_in_year(year);
|
||||
byte ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern byte g_date_get_sunday_weeks_in_year(ushort year);
|
||||
|
||||
public static byte GetSundayWeeksInYear(ushort year) {
|
||||
byte raw_ret = g_date_get_sunday_weeks_in_year(year);
|
||||
byte ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_is_leap_year(ushort year);
|
||||
|
||||
public static bool IsLeapYear(ushort year) {
|
||||
bool raw_ret = g_date_is_leap_year(year);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern UIntPtr g_date_strftime(IntPtr s, UIntPtr slen, IntPtr format, IntPtr date);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_valid_day(byte day);
|
||||
|
||||
public static bool ValidDay(byte day) {
|
||||
bool raw_ret = g_date_valid_day(day);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_valid_dmy(byte day, int month, ushort year);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_valid_julian(uint julian_date);
|
||||
|
||||
public static bool ValidJulian(uint julian_date) {
|
||||
bool raw_ret = g_date_valid_julian(julian_date);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_valid_month(int month);
|
||||
|
||||
public static bool ValidMonth(int month) {
|
||||
bool raw_ret = g_date_valid_month(month);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_valid_weekday(int weekday);
|
||||
|
||||
public static bool ValidWeekday(int weekday) {
|
||||
bool raw_ret = g_date_valid_weekday(weekday);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_valid_year(ushort 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) {}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_new();
|
||||
|
||||
public Date ()
|
||||
{
|
||||
Raw = g_date_new();
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_new_dmy(byte day, int month, ushort year);
|
||||
|
||||
public Date (byte day, int month, ushort year)
|
||||
{
|
||||
Raw = g_date_new_dmy(day, month, year);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_new_julian(uint julian_day);
|
||||
|
||||
public Date (uint julian_day)
|
||||
{
|
||||
Raw = g_date_new_julian(julian_day);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_free(IntPtr raw);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
512
glib/DateTime.cs
Normal file
512
glib/DateTime.cs
Normal file
|
@ -0,0 +1,512 @@
|
|||
// 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 {
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr 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;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add(IntPtr raw, long timespan);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add_days(IntPtr raw, int 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add_full(IntPtr raw, int years, int months, int days, int hours, int minutes, double seconds);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add_hours(IntPtr raw, int 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add_minutes(IntPtr raw, int 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add_months(IntPtr raw, int 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add_seconds(IntPtr raw, double 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add_weeks(IntPtr raw, int 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_add_years(IntPtr raw, int 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern long g_date_time_difference(IntPtr raw, IntPtr begin);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_format(IntPtr raw, IntPtr 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_day_of_month(IntPtr raw);
|
||||
|
||||
public int DayOfMonth {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_day_of_month(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_day_of_week(IntPtr raw);
|
||||
|
||||
public int DayOfWeek {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_day_of_week(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_day_of_year(IntPtr raw);
|
||||
|
||||
public int DayOfYear {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_day_of_year(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_hour(IntPtr raw);
|
||||
|
||||
public int Hour {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_hour(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_microsecond(IntPtr raw);
|
||||
|
||||
public int Microsecond {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_microsecond(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_minute(IntPtr raw);
|
||||
|
||||
public int Minute {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_minute(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_month(IntPtr raw);
|
||||
|
||||
public int Month {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_month(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_second(IntPtr raw);
|
||||
|
||||
public int Second {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_second(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern double g_date_time_get_seconds(IntPtr raw);
|
||||
|
||||
public double Seconds {
|
||||
get {
|
||||
double raw_ret = g_date_time_get_seconds(Handle);
|
||||
double ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_get_timezone_abbreviation(IntPtr raw);
|
||||
|
||||
public string TimezoneAbbreviation {
|
||||
get {
|
||||
IntPtr raw_ret = g_date_time_get_timezone_abbreviation(Handle);
|
||||
string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern long g_date_time_get_utc_offset(IntPtr raw);
|
||||
|
||||
public long UtcOffset {
|
||||
get {
|
||||
long raw_ret = g_date_time_get_utc_offset(Handle);
|
||||
long ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_week_numbering_year(IntPtr raw);
|
||||
|
||||
public int WeekNumberingYear {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_week_numbering_year(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_week_of_year(IntPtr raw);
|
||||
|
||||
public int WeekOfYear {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_week_of_year(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_get_year(IntPtr raw);
|
||||
|
||||
public int Year {
|
||||
get {
|
||||
int raw_ret = g_date_time_get_year(Handle);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_time_get_ymd(IntPtr raw, out int year, out int month, out int day);
|
||||
|
||||
public void GetYmd(out int year, out int month, out int day) {
|
||||
g_date_time_get_ymd(Handle, out year, out month, out day);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_time_is_daylight_savings(IntPtr raw);
|
||||
|
||||
public bool IsDaylightSavings {
|
||||
get {
|
||||
bool raw_ret = g_date_time_is_daylight_savings(Handle);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_to_local(IntPtr raw);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_time_to_timeval(IntPtr raw, IntPtr tv);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_to_timezone(IntPtr raw, IntPtr tz);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern long g_date_time_to_unix(IntPtr raw);
|
||||
|
||||
public long ToUnix() {
|
||||
long raw_ret = g_date_time_to_unix(Handle);
|
||||
long ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_to_utc(IntPtr raw);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_date_time_compare(IntPtr dt1, IntPtr dt2);
|
||||
|
||||
public static int Compare(IntPtr dt1, IntPtr dt2) {
|
||||
int raw_ret = g_date_time_compare(dt1, dt2);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_date_time_equal(IntPtr dt1, IntPtr dt2);
|
||||
|
||||
public static bool Equal(IntPtr dt1, IntPtr dt2) {
|
||||
bool raw_ret = g_date_time_equal(dt1, dt2);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern uint g_date_time_hash(IntPtr datetime);
|
||||
|
||||
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) {}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new(IntPtr tz, int year, int month, int day, int hour, int minute, double seconds);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_from_timeval_local(IntPtr tv);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_from_timeval_utc(IntPtr tv);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_from_unix_local(long t);
|
||||
|
||||
public DateTime (long t)
|
||||
{
|
||||
Raw = g_date_time_new_from_unix_local(t);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_from_unix_utc(long t);
|
||||
|
||||
public static DateTime NewFromUnixUtc(long t)
|
||||
{
|
||||
DateTime result = new DateTime (g_date_time_new_from_unix_utc(t));
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_local(int year, int month, int day, int hour, int minute, double seconds);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_now(IntPtr tz);
|
||||
|
||||
public DateTime (GLib.TimeZone tz)
|
||||
{
|
||||
Raw = g_date_time_new_now(tz == null ? IntPtr.Zero : tz.Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_now_local();
|
||||
|
||||
public DateTime ()
|
||||
{
|
||||
Raw = g_date_time_new_now_local();
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_now_utc();
|
||||
|
||||
public static DateTime NewNowUtc()
|
||||
{
|
||||
DateTime result = new DateTime (g_date_time_new_now_utc());
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_new_utc(int year, int month, int day, int hour, int minute, double seconds);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_date_time_ref(IntPtr raw);
|
||||
|
||||
protected override void Ref (IntPtr raw)
|
||||
{
|
||||
if (!Owned) {
|
||||
g_date_time_ref (raw);
|
||||
Owned = true;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_date_time_unref(IntPtr raw);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
92
glib/GLibSharp.SourceDummyMarshalNative.cs
Normal file
92
glib/GLibSharp.SourceDummyMarshalNative.cs
Normal 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
|
||||
}
|
95
glib/GLibSharp.SourceFuncNative.cs
Normal file
95
glib/GLibSharp.SourceFuncNative.cs
Normal 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
|
||||
}
|
|
@ -38,13 +38,13 @@ namespace GLib {
|
|||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_main_context_ref (IntPtr raw);
|
||||
|
||||
internal MainContext (IntPtr raw)
|
||||
public MainContext (IntPtr raw)
|
||||
{
|
||||
handle = raw;
|
||||
g_main_context_ref (handle);
|
||||
}
|
||||
|
||||
internal IntPtr Handle {
|
||||
public IntPtr Handle {
|
||||
get {
|
||||
return handle;
|
||||
}
|
||||
|
|
|
@ -19,9 +19,19 @@ POLICY_CONFIGS = $(addsuffix .config, $(addprefix policy., $(POLICY_VERSIONS)))
|
|||
|
||||
references =
|
||||
|
||||
# TODO: auto-generate at compile time the following classes:
|
||||
# Cond, Date, DateTime, Mutex, PollFD, RecMutex, (half)Source,
|
||||
# SourceCallbackFuncs, SourceDummyMarshal, SourceFunc,
|
||||
# SourceFuncNative, SourceFuncs, TimeVal, TimeZone
|
||||
# (to do that, we need to fill missing pieces in glib's
|
||||
# gobject-introspection metadata upstream)
|
||||
|
||||
sources = \
|
||||
Argv.cs \
|
||||
ConnectBeforeAttribute.cs \
|
||||
Cond.cs \
|
||||
Date.cs \
|
||||
DateTime.cs \
|
||||
DefaultSignalHandlerAttribute.cs \
|
||||
DestroyNotify.cs \
|
||||
ExceptionManager.cs \
|
||||
|
@ -48,23 +58,34 @@ sources = \
|
|||
Markup.cs \
|
||||
Marshaller.cs \
|
||||
MissingIntPtrCtorException.cs \
|
||||
Mutex.cs \
|
||||
NotifyHandler.cs \
|
||||
Object.cs \
|
||||
ObjectManager.cs \
|
||||
Opaque.cs \
|
||||
ParamSpec.cs \
|
||||
PollFD.cs \
|
||||
Priority.cs \
|
||||
PropertyAttribute.cs \
|
||||
PtrArray.cs \
|
||||
RecMutex.cs \
|
||||
Signal.cs \
|
||||
SignalArgs.cs \
|
||||
SignalAttribute.cs \
|
||||
SignalClosure.cs \
|
||||
SList.cs \
|
||||
Source.cs \
|
||||
SourceFunc.cs \
|
||||
SourceFuncs.cs \
|
||||
SourceDummyMarshal.cs \
|
||||
GLibSharp.SourceFuncNative.cs \
|
||||
GLibSharp.SourceDummyMarshalNative.cs \
|
||||
SourceCallbackFuncs.cs \
|
||||
Spawn.cs \
|
||||
Thread.cs \
|
||||
Timeout.cs \
|
||||
TimeVal.cs \
|
||||
TimeZone.cs \
|
||||
ToggleRef.cs \
|
||||
TypeFundamentals.cs \
|
||||
TypeInitializerAttribute.cs \
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace GLib {
|
|||
return ret.Replace ("%", "%%");
|
||||
}
|
||||
|
||||
internal static IntPtr StringArrayToStrvPtr (string[] strs)
|
||||
public static IntPtr StringArrayToStrvPtr (string[] strs)
|
||||
{
|
||||
IntPtr[] ptrs = StringArrayToNullTermPointer (strs);
|
||||
IntPtr ret = g_malloc (new UIntPtr ((ulong) (ptrs.Length * IntPtr.Size)));
|
||||
|
@ -178,6 +178,11 @@ namespace GLib {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static IntPtr StringArrayToNullTermStrvPointer (string[] strs)
|
||||
{
|
||||
return StringArrayToStrvPtr (strs);
|
||||
}
|
||||
|
||||
public static IntPtr[] StringArrayToNullTermPointer (string[] strs)
|
||||
{
|
||||
if (strs == null)
|
||||
|
@ -343,15 +348,15 @@ namespace GLib {
|
|||
return unmarshal_32 (array, argc);
|
||||
}
|
||||
|
||||
static DateTime local_epoch = new DateTime (1970, 1, 1, 0, 0, 0);
|
||||
static int utc_offset = (int) (TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.Now)).TotalSeconds;
|
||||
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 (DateTime time)
|
||||
public static IntPtr DateTimeTotime_t (System.DateTime time)
|
||||
{
|
||||
return new IntPtr (((long)time.Subtract (local_epoch).TotalSeconds) - utc_offset);
|
||||
}
|
||||
|
||||
public static DateTime time_tToDateTime (IntPtr time_t)
|
||||
public static System.DateTime time_tToDateTime (IntPtr time_t)
|
||||
{
|
||||
return local_epoch.AddSeconds (time_t.ToInt64 () + utc_offset);
|
||||
}
|
||||
|
@ -458,6 +463,39 @@ namespace GLib {
|
|||
|
||||
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 (typeof (T)));
|
||||
}
|
||||
|
||||
return res.ToArray ();
|
||||
}
|
||||
|
||||
public static IntPtr StructArrayToNullTerminatedStructArrayIntPtr<T> (T[] InputArray)
|
||||
{
|
||||
int intPtrSize = Marshal.SizeOf (typeof (IntPtr));
|
||||
IntPtr mem = Marshal.AllocHGlobal ((InputArray.Length + 1) * intPtrSize);
|
||||
|
||||
for (int i = 0; i < InputArray.Length; i++) {
|
||||
IntPtr structPtr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
55
glib/Mutex.cs
Normal file
55
glib/Mutex.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// 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 {
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_mutex_clear(IntPtr raw);
|
||||
|
||||
public void Clear() {
|
||||
g_mutex_clear(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_mutex_init(IntPtr raw);
|
||||
|
||||
public void Init() {
|
||||
g_mutex_init(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_mutex_lock(IntPtr raw);
|
||||
|
||||
public void Lock() {
|
||||
g_mutex_lock(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_mutex_trylock(IntPtr raw);
|
||||
|
||||
public bool Trylock() {
|
||||
bool raw_ret = g_mutex_trylock(Handle);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_mutex_unlock(IntPtr raw);
|
||||
|
||||
public void Unlock() {
|
||||
g_mutex_unlock(Handle);
|
||||
}
|
||||
|
||||
public Mutex(IntPtr raw) : base(raw) {}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
67
glib/PollFD.cs
Normal file
67
glib/PollFD.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
// 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));
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr 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
|
||||
}
|
||||
}
|
55
glib/RecMutex.cs
Normal file
55
glib/RecMutex.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// 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 {
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_rec_mutex_clear(IntPtr raw);
|
||||
|
||||
public void Clear() {
|
||||
g_rec_mutex_clear(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_rec_mutex_init(IntPtr raw);
|
||||
|
||||
public void Init() {
|
||||
g_rec_mutex_init(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_rec_mutex_lock(IntPtr raw);
|
||||
|
||||
public void Lock() {
|
||||
g_rec_mutex_lock(Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_rec_mutex_trylock(IntPtr raw);
|
||||
|
||||
public bool Trylock() {
|
||||
bool raw_ret = g_rec_mutex_trylock(Handle);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_rec_mutex_unlock(IntPtr raw);
|
||||
|
||||
public void Unlock() {
|
||||
g_rec_mutex_unlock(Handle);
|
||||
}
|
||||
|
||||
public RecMutex(IntPtr raw) : base(raw) {}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
347
glib/Source.cs
347
glib/Source.cs
|
@ -43,10 +43,11 @@ namespace GLib {
|
|||
proxy_handler = null;
|
||||
}
|
||||
}
|
||||
|
||||
public class Source {
|
||||
|
||||
public partial class Source : GLib.Opaque {
|
||||
|
||||
private Source () {}
|
||||
|
||||
|
||||
internal static Hashtable source_handlers = new Hashtable ();
|
||||
|
||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
|
@ -58,5 +59,343 @@ namespace GLib {
|
|||
source_handlers.Remove (tag);
|
||||
return g_source_remove (tag);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_get_context(IntPtr raw);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_source_get_priority(IntPtr raw);
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_set_priority(IntPtr raw, int 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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_get_name(IntPtr raw);
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_set_name(IntPtr raw, IntPtr 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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr 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;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_add_child_source(IntPtr raw, IntPtr child_source);
|
||||
|
||||
public void AddChildSource(GLib.Source child_source) {
|
||||
g_source_add_child_source(Handle, child_source == null ? IntPtr.Zero : child_source.Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_add_poll(IntPtr raw, IntPtr fd);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern uint g_source_attach(IntPtr raw, IntPtr context);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_source_get_can_recurse(IntPtr raw);
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_set_can_recurse(IntPtr raw, bool 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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_get_current_time(IntPtr raw, IntPtr timeval);
|
||||
|
||||
[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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern uint g_source_get_id(IntPtr raw);
|
||||
|
||||
public uint Id {
|
||||
get {
|
||||
uint raw_ret = g_source_get_id(Handle);
|
||||
uint ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern long g_source_get_ready_time(IntPtr raw);
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_set_ready_time(IntPtr raw, long 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);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern long g_source_get_time(IntPtr raw);
|
||||
|
||||
public long Time {
|
||||
get {
|
||||
long raw_ret = g_source_get_time(Handle);
|
||||
long ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_source_is_destroyed(IntPtr raw);
|
||||
|
||||
public bool IsDestroyed {
|
||||
get {
|
||||
bool raw_ret = g_source_is_destroyed(Handle);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_modify_unix_fd(IntPtr raw, IntPtr tag, int new_events);
|
||||
|
||||
public void ModifyUnixFd(IntPtr tag, GLib.IOCondition new_events) {
|
||||
g_source_modify_unix_fd(Handle, tag, (int) new_events);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_source_query_unix_fd(IntPtr raw, IntPtr tag);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_remove_child_source(IntPtr raw, IntPtr child_source);
|
||||
|
||||
public void RemoveChildSource(GLib.Source child_source) {
|
||||
g_source_remove_child_source(Handle, child_source == null ? IntPtr.Zero : child_source.Handle);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_remove_poll(IntPtr raw, IntPtr fd);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_remove_unix_fd(IntPtr raw, IntPtr tag);
|
||||
|
||||
public void RemoveUnixFd(IntPtr tag) {
|
||||
g_source_remove_unix_fd(Handle, tag);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_set_callback_indirect(IntPtr raw, IntPtr callback_data, IntPtr callback_funcs);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_set_funcs(IntPtr raw, IntPtr value);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* commented out because there is already a custom implementation for Remove
|
||||
*
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_source_remove(uint tag);
|
||||
|
||||
public static bool Remove(uint tag) {
|
||||
bool raw_ret = g_source_remove(tag);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_source_remove_by_funcs_user_data(IntPtr funcs, IntPtr 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_source_remove_by_user_data(IntPtr 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_set_name_by_id(uint tag, IntPtr name);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public Source(IntPtr raw) : base(raw) {}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_new(IntPtr source_funcs, uint struct_size);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_ref(IntPtr raw);
|
||||
|
||||
protected override void Ref (IntPtr raw)
|
||||
{
|
||||
if (!Owned) {
|
||||
g_source_ref (raw);
|
||||
Owned = true;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_unref(IntPtr raw);
|
||||
|
||||
protected override void Unref (IntPtr raw)
|
||||
{
|
||||
if (Owned) {
|
||||
g_source_unref (raw);
|
||||
Owned = false;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_destroy(IntPtr raw);
|
||||
|
||||
protected override void Free (IntPtr raw)
|
||||
{
|
||||
g_source_destroy (raw);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
44
glib/SourceCallbackFuncs.cs
Normal file
44
glib/SourceCallbackFuncs.cs
Normal 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
|
||||
}
|
||||
}
|
10
glib/SourceDummyMarshal.cs
Normal file
10
glib/SourceDummyMarshal.cs
Normal 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();
|
||||
|
||||
}
|
10
glib/SourceFunc.cs
Normal file
10
glib/SourceFunc.cs
Normal 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);
|
||||
|
||||
}
|
46
glib/SourceFuncs.cs
Normal file
46
glib/SourceFuncs.cs
Normal 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
|
||||
}
|
||||
}
|
105
glib/TimeVal.cs
Normal file
105
glib/TimeVal.cs
Normal file
|
@ -0,0 +1,105 @@
|
|||
// 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));
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_time_val_add(IntPtr raw, IntPtr microseconds);
|
||||
|
||||
public void Add(long microseconds) {
|
||||
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
|
||||
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);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_time_val_to_iso8601(IntPtr raw);
|
||||
|
||||
public string ToIso8601() {
|
||||
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
|
||||
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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_time_val_from_iso8601(IntPtr iso_date, IntPtr time_);
|
||||
|
||||
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 (typeof (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
|
||||
}
|
||||
}
|
146
glib/TimeZone.cs
Normal file
146
glib/TimeZone.cs
Normal file
|
@ -0,0 +1,146 @@
|
|||
// 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 {
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr 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;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_time_zone_adjust_time(IntPtr raw, int type, long 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;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_time_zone_find_interval(IntPtr raw, int type, long time_);
|
||||
|
||||
public int FindInterval(int type, long time_) {
|
||||
int raw_ret = g_time_zone_find_interval(Handle, type, time_);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_time_zone_get_abbreviation(IntPtr raw, int interval);
|
||||
|
||||
public string GetAbbreviation(int interval) {
|
||||
IntPtr raw_ret = g_time_zone_get_abbreviation(Handle, interval);
|
||||
string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int g_time_zone_get_offset(IntPtr raw, int interval);
|
||||
|
||||
public int GetOffset(int interval) {
|
||||
int raw_ret = g_time_zone_get_offset(Handle, interval);
|
||||
int ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_time_zone_is_dst(IntPtr raw, int interval);
|
||||
|
||||
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) {}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_time_zone_new(IntPtr identifier);
|
||||
|
||||
public TimeZone (string identifier)
|
||||
{
|
||||
IntPtr native_identifier = GLib.Marshaller.StringToPtrGStrdup (identifier);
|
||||
Raw = g_time_zone_new(native_identifier);
|
||||
GLib.Marshaller.Free (native_identifier);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_time_zone_new_local();
|
||||
|
||||
public TimeZone ()
|
||||
{
|
||||
Raw = g_time_zone_new_local();
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_time_zone_new_utc();
|
||||
|
||||
public static TimeZone NewUtc()
|
||||
{
|
||||
TimeZone result = new TimeZone (g_time_zone_new_utc());
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_time_zone_ref(IntPtr raw);
|
||||
|
||||
protected override void Ref (IntPtr raw)
|
||||
{
|
||||
if (!Owned) {
|
||||
g_time_zone_ref (raw);
|
||||
Owned = true;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_time_zone_unref(IntPtr raw);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
|
@ -421,10 +421,14 @@ namespace GLib {
|
|||
return (GLib.Opaque) this;
|
||||
|
||||
MethodInfo mi = t.GetMethod ("New", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
|
||||
if (mi == null)
|
||||
return Marshal.PtrToStructure (boxed_ptr, t);
|
||||
else
|
||||
if (mi != null)
|
||||
return mi.Invoke (null, new object[] {boxed_ptr});
|
||||
|
||||
ConstructorInfo 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
|
||||
|
@ -548,8 +552,15 @@ namespace GLib {
|
|||
|
||||
internal void Update (object val)
|
||||
{
|
||||
if (GType.Is (type, GType.Boxed) && !(val is IWrapper))
|
||||
Marshal.StructureToPtr (val, g_value_get_boxed (ref this), false);
|
||||
Type t = GType.LookupType (type);
|
||||
if (GType.Is (type, GType.Boxed) && !(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)
|
||||
Marshal.StructureToPtr (val, boxed_ptr, false);
|
||||
else
|
||||
mi.Invoke (val, null);
|
||||
}
|
||||
}
|
||||
|
||||
bool HoldsFlags {
|
||||
|
|
|
@ -87,8 +87,15 @@
|
|||
<Compile Include="Variant.cs" />
|
||||
<Compile Include="VariantType.cs" />
|
||||
<Compile Include="GLibSynchronizationContext.cs" />
|
||||
<Compile Include="Mutex.cs" />
|
||||
<Compile Include="RecMutex.cs" />
|
||||
<Compile Include="Cond.cs" />
|
||||
<Compile Include="Date.cs" />
|
||||
<Compile Include="DateTime.cs" />
|
||||
<Compile Include="TimeVal.cs" />
|
||||
<Compile Include="TimeZone.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
// gapi-fixup.cs - xml alteration engine.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
// Authors:
|
||||
// Mike Kestner <mkestner@speakeasy.net>
|
||||
// Stephan Sundermann <stephansundermann@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2003 Mike Kestner
|
||||
// Copyright (c) 2013 Stephan Sundermann
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the GNU General Public
|
||||
|
@ -92,6 +95,26 @@ namespace GtkSharp.Parsing {
|
|||
XPathNavigator meta_nav = meta_doc.CreateNavigator ();
|
||||
XPathNavigator api_nav = api_doc.CreateNavigator ();
|
||||
|
||||
XPathNodeIterator copy_iter = meta_nav.Select ("/metadata/copy-node");
|
||||
while (copy_iter.MoveNext ()) {
|
||||
string path = copy_iter.Current.GetAttribute ("path", String.Empty);
|
||||
XPathExpression expr = api_nav.Compile (path);
|
||||
string parent = copy_iter.Current.Value;
|
||||
XPathNodeIterator parent_iter = api_nav.Select (parent);
|
||||
bool matched = false;
|
||||
while (parent_iter.MoveNext ()) {
|
||||
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
|
||||
XPathNodeIterator path_iter = parent_iter.Current.Clone ().Select (expr);
|
||||
while (path_iter.MoveNext ()) {
|
||||
XmlNode node = ((IHasXmlNode)path_iter.Current).GetNode ();
|
||||
parent_node.AppendChild (node.Clone ());
|
||||
}
|
||||
matched = true;
|
||||
}
|
||||
if (!matched)
|
||||
Console.WriteLine ("Warning: <copy-node path=\"{0}\"/> matched no nodes", path);
|
||||
}
|
||||
|
||||
XPathNodeIterator rmv_iter = meta_nav.Select ("/metadata/remove-node");
|
||||
while (rmv_iter.MoveNext ()) {
|
||||
string path = rmv_iter.Current.GetAttribute ("path", "");
|
||||
|
|
Loading…
Reference in a new issue