mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-07 07:23:18 +02:00
generator: Convert all .cs files to Unix line endings
There are no real code changes in this commit.
This commit is contained in:
parent
4f29defd5c
commit
b8b1cfa5d7
@ -1,30 +1,30 @@
|
|||||||
// GtkSharp.Generation.AliasGen.cs - The Alias type Generatable.
|
// GtkSharp.Generation.AliasGen.cs - The Alias type Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003 Mike Kestner
|
// Copyright (c) 2003 Mike Kestner
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class AliasGen : SimpleBase {
|
public class AliasGen : SimpleBase {
|
||||||
|
|
||||||
public AliasGen (string ctype, string type) : base (ctype, type, String.Empty) {}
|
public AliasGen (string ctype, string type) : base (ctype, type, String.Empty) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||
// GtkSharp.Generation.BoxedGen.cs - The Boxed Generatable.
|
// GtkSharp.Generation.BoxedGen.cs - The Boxed Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2003-2004 Novell, Inc.
|
// Copyright (c) 2003-2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class BoxedGen : StructBase {
|
public class BoxedGen : StructBase {
|
||||||
|
|
||||||
public BoxedGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
public BoxedGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
Method copy = methods["Copy"] as Method;
|
Method copy = methods["Copy"] as Method;
|
||||||
Method free = methods["Free"] as Method;
|
Method free = methods["Free"] as Method;
|
||||||
methods.Remove ("Copy");
|
methods.Remove ("Copy");
|
||||||
methods.Remove ("Free");
|
methods.Remove ("Free");
|
||||||
|
|
||||||
gen_info.CurrentType = QualifiedName;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||||
base.Generate (gen_info);
|
base.Generate (gen_info);
|
||||||
sw.WriteLine ("\t\tpublic static explicit operator GLib.Value (" + QualifiedName + " boxed)");
|
sw.WriteLine ("\t\tpublic static explicit operator GLib.Value (" + QualifiedName + " boxed)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
|
|
||||||
sw.WriteLine ("\t\t\tGLib.Value val = GLib.Value.Empty;");
|
sw.WriteLine ("\t\t\tGLib.Value val = GLib.Value.Empty;");
|
||||||
sw.WriteLine ("\t\t\tval.Init (" + QualifiedName + ".GType);");
|
sw.WriteLine ("\t\t\tval.Init (" + QualifiedName + ".GType);");
|
||||||
sw.WriteLine ("\t\t\tval.Val = boxed;");
|
sw.WriteLine ("\t\t\tval.Val = boxed;");
|
||||||
sw.WriteLine ("\t\t\treturn val;");
|
sw.WriteLine ("\t\t\treturn val;");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tpublic static explicit operator " + QualifiedName + " (GLib.Value val)");
|
sw.WriteLine ("\t\tpublic static explicit operator " + QualifiedName + " (GLib.Value val)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
|
|
||||||
sw.WriteLine ("\t\t\treturn (" + QualifiedName + ") val.Val;");
|
sw.WriteLine ("\t\t\treturn (" + QualifiedName + ") val.Val;");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
|
|
||||||
if (copy != null && copy.IsDeprecated) {
|
if (copy != null && copy.IsDeprecated) {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t[Obsolete(\"This is a no-op\")]");
|
sw.WriteLine ("\t\t[Obsolete(\"This is a no-op\")]");
|
||||||
sw.WriteLine ("\t\tpublic " + QualifiedName + " Copy() {");
|
sw.WriteLine ("\t\tpublic " + QualifiedName + " Copy() {");
|
||||||
sw.WriteLine ("\t\t\treturn this;");
|
sw.WriteLine ("\t\t\treturn this;");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (free != null && free.IsDeprecated) {
|
if (free != null && free.IsDeprecated) {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t[Obsolete(\"This is a no-op\")]");
|
sw.WriteLine ("\t\t[Obsolete(\"This is a no-op\")]");
|
||||||
sw.WriteLine ("\t\tpublic " + QualifiedName + " Free () {");
|
sw.WriteLine ("\t\tpublic " + QualifiedName + " Free () {");
|
||||||
sw.WriteLine ("\t\t\treturn this;");
|
sw.WriteLine ("\t\t\treturn this;");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
gen_info.Writer = null;
|
gen_info.Writer = null;
|
||||||
Statistics.BoxedCount++;
|
Statistics.BoxedCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,63 +1,63 @@
|
|||||||
// GtkSharp.Generation.ByRefGen.cs - The ByRef type Generatable.
|
// GtkSharp.Generation.ByRefGen.cs - The ByRef type Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003 Mike Kestner
|
// Copyright (c) 2003 Mike Kestner
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class ByRefGen : SimpleBase, IManualMarshaler {
|
public class ByRefGen : SimpleBase, IManualMarshaler {
|
||||||
|
|
||||||
public ByRefGen (string ctype, string type) : base (ctype, type, type + ".Empty") {}
|
public ByRefGen (string ctype, string type) : base (ctype, type, type + ".Empty") {}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return "IntPtr";
|
return "IntPtr";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var_name)
|
public override string CallByName (string var_name)
|
||||||
{
|
{
|
||||||
return "native_" + var_name;
|
return "native_" + var_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AllocNative ()
|
public string AllocNative ()
|
||||||
{
|
{
|
||||||
return "Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + QualifiedName + ")))";
|
return "Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + QualifiedName + ")))";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AllocNative (string var_name)
|
public string AllocNative (string var_name)
|
||||||
{
|
{
|
||||||
return "GLib.Marshaller.StructureToPtrAlloc (" + var_name + ")";
|
return "GLib.Marshaller.StructureToPtrAlloc (" + var_name + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative (string var_name)
|
public override string FromNative (string var_name)
|
||||||
{
|
{
|
||||||
return String.Format ("({0}) Marshal.PtrToStructure ({1}, typeof ({0}))", QualifiedName, var_name);
|
return String.Format ("({0}) Marshal.PtrToStructure ({1}, typeof ({0}))", QualifiedName, var_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReleaseNative (string var_name)
|
public string ReleaseNative (string var_name)
|
||||||
{
|
{
|
||||||
return "Marshal.FreeHGlobal (" + var_name + ")";
|
return "Marshal.FreeHGlobal (" + var_name + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,45 +1,45 @@
|
|||||||
// GtkSharp.Generation.ChildProperty.cs - GtkContainer child properties
|
// GtkSharp.Generation.ChildProperty.cs - GtkContainer child properties
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class ChildProperty : Property {
|
public class ChildProperty : Property {
|
||||||
|
|
||||||
public ChildProperty (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
public ChildProperty (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
||||||
|
|
||||||
protected override string PropertyAttribute (string qpname) {
|
protected override string PropertyAttribute (string qpname) {
|
||||||
return "[Gtk.ChildProperty (" + qpname + ")]";
|
return "[Gtk.ChildProperty (" + qpname + ")]";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string RawGetter (string qpname) {
|
protected override string RawGetter (string qpname) {
|
||||||
return "parent.ChildGetProperty (child, " + qpname + ")";
|
return "parent.ChildGetProperty (child, " + qpname + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string RawSetter (string qpname) {
|
protected override string RawSetter (string qpname) {
|
||||||
return "parent.ChildSetProperty(child, " + qpname + ", val)";
|
return "parent.ChildSetProperty(child, " + qpname + ", val)";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,93 +1,93 @@
|
|||||||
// GtkSharp.Generation.ClassGen.cs - The Class Generatable.
|
// GtkSharp.Generation.ClassGen.cs - The Class Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class ClassGen : ClassBase {
|
public class ClassGen : ClassBase {
|
||||||
|
|
||||||
public ClassGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
public ClassGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
||||||
|
|
||||||
public override string AssignToName {
|
public override string AssignToName {
|
||||||
get {
|
get {
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName ()
|
public override string CallByName ()
|
||||||
{
|
{
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var)
|
public override string CallByName (string var)
|
||||||
{
|
{
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative (string var)
|
public override string FromNative (string var)
|
||||||
{
|
{
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = QualifiedName;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream(Name);
|
||||||
|
|
||||||
sw.WriteLine ("namespace " + NS + " {");
|
sw.WriteLine ("namespace " + NS + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
sw.WriteLine ("#region Autogenerated code");
|
sw.WriteLine ("#region Autogenerated code");
|
||||||
if (IsDeprecated)
|
if (IsDeprecated)
|
||||||
sw.WriteLine ("\t[Obsolete]");
|
sw.WriteLine ("\t[Obsolete]");
|
||||||
sw.Write ("\t{0} partial class " + Name, IsInternal ? "internal" : "public");
|
sw.Write ("\t{0} partial class " + Name, IsInternal ? "internal" : "public");
|
||||||
sw.WriteLine (" {");
|
sw.WriteLine (" {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
GenProperties (gen_info, null);
|
GenProperties (gen_info, null);
|
||||||
GenMethods (gen_info, null, null);
|
GenMethods (gen_info, null, null);
|
||||||
|
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
|
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
gen_info.Writer = null;
|
gen_info.Writer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,121 +1,121 @@
|
|||||||
// GtkSharp.Generation.CodeGenerator.cs - The main code generation engine.
|
// GtkSharp.Generation.CodeGenerator.cs - The main code generation engine.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2003-2004 Novell Inc.
|
// Copyright (c) 2003-2004 Novell Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class CodeGenerator {
|
public class CodeGenerator {
|
||||||
|
|
||||||
public static int Main (string[] args)
|
public static int Main (string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length < 2) {
|
if (args.Length < 2) {
|
||||||
Console.WriteLine ("Usage: codegen --generate <filename1...>");
|
Console.WriteLine ("Usage: codegen --generate <filename1...>");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool generate = false;
|
bool generate = false;
|
||||||
string dir = "";
|
string dir = "";
|
||||||
string assembly_name = "";
|
string assembly_name = "";
|
||||||
string glue_filename = "";
|
string glue_filename = "";
|
||||||
string glue_includes = "";
|
string glue_includes = "";
|
||||||
string gluelib_name = "";
|
string gluelib_name = "";
|
||||||
|
|
||||||
SymbolTable table = SymbolTable.Table;
|
SymbolTable table = SymbolTable.Table;
|
||||||
ArrayList gens = new ArrayList ();
|
ArrayList gens = new ArrayList ();
|
||||||
foreach (string arg in args) {
|
foreach (string arg in args) {
|
||||||
if (arg.StartsWith ("--customdir=")) {
|
if (arg.StartsWith ("--customdir=")) {
|
||||||
Console.WriteLine ("Using .custom files is not supported anymore, use partial classes instead.");
|
Console.WriteLine ("Using .custom files is not supported anymore, use partial classes instead.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
string filename = arg;
|
string filename = arg;
|
||||||
if (arg == "--generate") {
|
if (arg == "--generate") {
|
||||||
generate = true;
|
generate = true;
|
||||||
continue;
|
continue;
|
||||||
} else if (arg == "--include") {
|
} else if (arg == "--include") {
|
||||||
generate = false;
|
generate = false;
|
||||||
continue;
|
continue;
|
||||||
} else if (arg.StartsWith ("-I:")) {
|
} else if (arg.StartsWith ("-I:")) {
|
||||||
generate = false;
|
generate = false;
|
||||||
filename = filename.Substring (3);
|
filename = filename.Substring (3);
|
||||||
} else if (arg.StartsWith ("--outdir=")) {
|
} else if (arg.StartsWith ("--outdir=")) {
|
||||||
generate = false;
|
generate = false;
|
||||||
dir = arg.Substring (9);
|
dir = arg.Substring (9);
|
||||||
continue;
|
continue;
|
||||||
} else if (arg.StartsWith ("--assembly-name=")) {
|
} else if (arg.StartsWith ("--assembly-name=")) {
|
||||||
generate = false;
|
generate = false;
|
||||||
assembly_name = arg.Substring (16);
|
assembly_name = arg.Substring (16);
|
||||||
continue;
|
continue;
|
||||||
} else if (arg.StartsWith ("--glue-filename=")) {
|
} else if (arg.StartsWith ("--glue-filename=")) {
|
||||||
generate = false;
|
generate = false;
|
||||||
glue_filename = arg.Substring (16);
|
glue_filename = arg.Substring (16);
|
||||||
continue;
|
continue;
|
||||||
} else if (arg.StartsWith ("--glue-includes=")) {
|
} else if (arg.StartsWith ("--glue-includes=")) {
|
||||||
generate = false;
|
generate = false;
|
||||||
glue_includes = arg.Substring (16);
|
glue_includes = arg.Substring (16);
|
||||||
continue;
|
continue;
|
||||||
} else if (arg.StartsWith ("--gluelib-name=")) {
|
} else if (arg.StartsWith ("--gluelib-name=")) {
|
||||||
generate = false;
|
generate = false;
|
||||||
gluelib_name = arg.Substring (15);
|
gluelib_name = arg.Substring (15);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Parser p = new Parser ();
|
Parser p = new Parser ();
|
||||||
IGeneratable[] curr_gens = p.Parse (filename);
|
IGeneratable[] curr_gens = p.Parse (filename);
|
||||||
table.AddTypes (curr_gens);
|
table.AddTypes (curr_gens);
|
||||||
if (generate)
|
if (generate)
|
||||||
gens.AddRange (curr_gens);
|
gens.AddRange (curr_gens);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that everything is loaded, validate all the to-be-
|
// Now that everything is loaded, validate all the to-be-
|
||||||
// generated generatables and then remove the invalid ones.
|
// generated generatables and then remove the invalid ones.
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
foreach (IGeneratable gen in gens) {
|
foreach (IGeneratable gen in gens) {
|
||||||
if (!gen.Validate ())
|
if (!gen.Validate ())
|
||||||
invalids.Add (gen);
|
invalids.Add (gen);
|
||||||
}
|
}
|
||||||
foreach (IGeneratable gen in invalids)
|
foreach (IGeneratable gen in invalids)
|
||||||
gens.Remove (gen);
|
gens.Remove (gen);
|
||||||
|
|
||||||
GenerationInfo gen_info = null;
|
GenerationInfo gen_info = null;
|
||||||
if (dir != "" || assembly_name != "" || glue_filename != "" || glue_includes != "" || gluelib_name != "")
|
if (dir != "" || assembly_name != "" || glue_filename != "" || glue_includes != "" || gluelib_name != "")
|
||||||
gen_info = new GenerationInfo (dir, assembly_name, glue_filename, glue_includes, gluelib_name);
|
gen_info = new GenerationInfo (dir, assembly_name, glue_filename, glue_includes, gluelib_name);
|
||||||
|
|
||||||
foreach (IGeneratable gen in gens) {
|
foreach (IGeneratable gen in gens) {
|
||||||
if (gen_info == null)
|
if (gen_info == null)
|
||||||
gen.Generate ();
|
gen.Generate ();
|
||||||
else
|
else
|
||||||
gen.Generate (gen_info);
|
gen.Generate (gen_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectGen.GenerateMappers ();
|
ObjectGen.GenerateMappers ();
|
||||||
|
|
||||||
if (gen_info != null)
|
if (gen_info != null)
|
||||||
gen_info.CloseGlueWriter ();
|
gen_info.CloseGlueWriter ();
|
||||||
|
|
||||||
Statistics.Report();
|
Statistics.Report();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
// ConstFilenameGen.cs - The Const Filename type Generatable.
|
// ConstFilenameGen.cs - The Const Filename type Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2005 Novell, Inc.
|
// Copyright (c) 2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class ConstFilenameGen : SimpleBase, IManualMarshaler {
|
public class ConstFilenameGen : SimpleBase, IManualMarshaler {
|
||||||
|
|
||||||
public ConstFilenameGen (string ctype) : base (ctype, "string", "null") {}
|
public ConstFilenameGen (string ctype) : base (ctype, "string", "null") {}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return "IntPtr";
|
return "IntPtr";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative (string var)
|
public override string FromNative (string var)
|
||||||
{
|
{
|
||||||
return "GLib.Marshaller.FilenamePtrToString (" + var + ")";
|
return "GLib.Marshaller.FilenamePtrToString (" + var + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AllocNative (string managed_var)
|
public string AllocNative (string managed_var)
|
||||||
{
|
{
|
||||||
return "GLib.Marshaller.StringToFilenamePtr (" + managed_var + ")";
|
return "GLib.Marshaller.StringToFilenamePtr (" + managed_var + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReleaseNative (string native_var)
|
public string ReleaseNative (string native_var)
|
||||||
{
|
{
|
||||||
return "GLib.Marshaller.Free (" + native_var + ")";
|
return "GLib.Marshaller.Free (" + native_var + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,54 +1,54 @@
|
|||||||
// GtkSharp.Generation.ConstStringGen.cs - The Const String type Generatable.
|
// GtkSharp.Generation.ConstStringGen.cs - The Const String type Generatable.
|
||||||
//
|
//
|
||||||
// Author: Rachel Hestilow <rachel@nullenvoid.com>
|
// Author: Rachel Hestilow <rachel@nullenvoid.com>
|
||||||
// Mike Kestner <mkestner@novell.com>
|
// Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003 Rachel Hestilow
|
// Copyright (c) 2003 Rachel Hestilow
|
||||||
// Copyright (c) 2005 Novell, Inc.
|
// Copyright (c) 2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class ConstStringGen : SimpleBase, IManualMarshaler {
|
public class ConstStringGen : SimpleBase, IManualMarshaler {
|
||||||
|
|
||||||
public ConstStringGen (string ctype) : base (ctype, "string", "null") {}
|
public ConstStringGen (string ctype) : base (ctype, "string", "null") {}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return "IntPtr";
|
return "IntPtr";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative (string var)
|
public override string FromNative (string var)
|
||||||
{
|
{
|
||||||
return "GLib.Marshaller.Utf8PtrToString (" + var + ")";
|
return "GLib.Marshaller.Utf8PtrToString (" + var + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AllocNative (string managed_var)
|
public string AllocNative (string managed_var)
|
||||||
{
|
{
|
||||||
return "GLib.Marshaller.StringToPtrGStrdup (" + managed_var + ")";
|
return "GLib.Marshaller.StringToPtrGStrdup (" + managed_var + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReleaseNative (string native_var)
|
public string ReleaseNative (string native_var)
|
||||||
{
|
{
|
||||||
return "GLib.Marshaller.Free (" + native_var + ")";
|
return "GLib.Marshaller.Free (" + native_var + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,164 +1,164 @@
|
|||||||
// GtkSharp.Generation.Ctor.cs - The Constructor Generation Class.
|
// GtkSharp.Generation.Ctor.cs - The Constructor Generation Class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2004-2005 Novell, Inc.
|
// Copyright (c) 2004-2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class Ctor : MethodBase {
|
public class Ctor : MethodBase {
|
||||||
|
|
||||||
private bool preferred;
|
private bool preferred;
|
||||||
private string name;
|
private string name;
|
||||||
private bool needs_chaining = false;
|
private bool needs_chaining = false;
|
||||||
|
|
||||||
public Ctor (XmlElement elem, ClassBase implementor) : base (elem, implementor)
|
public Ctor (XmlElement elem, ClassBase implementor) : base (elem, implementor)
|
||||||
{
|
{
|
||||||
preferred = elem.GetAttributeAsBoolean ("preferred");
|
preferred = elem.GetAttributeAsBoolean ("preferred");
|
||||||
if (implementor is ObjectGen)
|
if (implementor is ObjectGen)
|
||||||
needs_chaining = true;
|
needs_chaining = true;
|
||||||
name = implementor.Name;
|
name = implementor.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Preferred {
|
public bool Preferred {
|
||||||
get { return preferred; }
|
get { return preferred; }
|
||||||
set { preferred = value; }
|
set { preferred = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string StaticName {
|
public string StaticName {
|
||||||
get {
|
get {
|
||||||
if (!IsStatic)
|
if (!IsStatic)
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
|
||||||
if (Name != null && Name != String.Empty)
|
if (Name != null && Name != String.Empty)
|
||||||
return Name;
|
return Name;
|
||||||
|
|
||||||
string[] toks = CName.Substring(CName.IndexOf("new")).Split ('_');
|
string[] toks = CName.Substring(CName.IndexOf("new")).Split ('_');
|
||||||
string result = String.Empty;
|
string result = String.Empty;
|
||||||
|
|
||||||
foreach (string tok in toks)
|
foreach (string tok in toks)
|
||||||
result += tok.Substring(0,1).ToUpper() + tok.Substring(1);
|
result += tok.Substring(0,1).ToUpper() + tok.Substring(1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateImport (StreamWriter sw)
|
void GenerateImport (StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\", CallingConvention = CallingConvention.Cdecl)]");
|
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\", CallingConvention = CallingConvention.Cdecl)]");
|
||||||
sw.WriteLine("\t\tstatic extern " + Safety + "IntPtr " + CName + "(" + Parameters.ImportSignature + ");");
|
sw.WriteLine("\t\tstatic extern " + Safety + "IntPtr " + CName + "(" + Parameters.ImportSignature + ");");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateStatic (GenerationInfo gen_info)
|
void GenerateStatic (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
sw.WriteLine("\t\t" + Protection + " static " + Safety + Modifiers + name + " " + StaticName + "(" + Signature + ")");
|
sw.WriteLine("\t\t" + Protection + " static " + Safety + Modifiers + name + " " + StaticName + "(" + Signature + ")");
|
||||||
sw.WriteLine("\t\t{");
|
sw.WriteLine("\t\t{");
|
||||||
|
|
||||||
Body.Initialize(gen_info, false, false, "");
|
Body.Initialize(gen_info, false, false, "");
|
||||||
|
|
||||||
sw.Write("\t\t\t" + name + " result = ");
|
sw.Write("\t\t\t" + name + " result = ");
|
||||||
if (container_type is StructBase)
|
if (container_type is StructBase)
|
||||||
sw.Write ("{0}.New (", name);
|
sw.Write ("{0}.New (", name);
|
||||||
else
|
else
|
||||||
sw.Write ("new {0} (", name);
|
sw.Write ("new {0} (", name);
|
||||||
sw.WriteLine (CName + "(" + Body.GetCallString (false) + "));");
|
sw.WriteLine (CName + "(" + Body.GetCallString (false) + "));");
|
||||||
Body.Finish (sw, "");
|
Body.Finish (sw, "");
|
||||||
Body.HandleException (sw, "");
|
Body.HandleException (sw, "");
|
||||||
sw.WriteLine ("\t\t\treturn result;");
|
sw.WriteLine ("\t\t\treturn result;");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate (GenerationInfo gen_info)
|
public void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
gen_info.CurrentMember = CName;
|
gen_info.CurrentMember = CName;
|
||||||
|
|
||||||
GenerateImport (sw);
|
GenerateImport (sw);
|
||||||
|
|
||||||
if (IsStatic)
|
if (IsStatic)
|
||||||
GenerateStatic (gen_info);
|
GenerateStatic (gen_info);
|
||||||
else {
|
else {
|
||||||
sw.WriteLine("\t\t{0} {1}{2} ({3}) {4}", Protection, Safety, name, Signature.ToString(), needs_chaining ? ": base (IntPtr.Zero)" : "");
|
sw.WriteLine("\t\t{0} {1}{2} ({3}) {4}", Protection, Safety, name, Signature.ToString(), needs_chaining ? ": base (IntPtr.Zero)" : "");
|
||||||
sw.WriteLine("\t\t{");
|
sw.WriteLine("\t\t{");
|
||||||
|
|
||||||
if (needs_chaining) {
|
if (needs_chaining) {
|
||||||
sw.WriteLine ("\t\t\tif (GetType () != typeof (" + name + ")) {");
|
sw.WriteLine ("\t\t\tif (GetType () != typeof (" + name + ")) {");
|
||||||
|
|
||||||
if (Parameters.Count == 0) {
|
if (Parameters.Count == 0) {
|
||||||
sw.WriteLine ("\t\t\t\tCreateNativeObject (new string [0], new GLib.Value[0]);");
|
sw.WriteLine ("\t\t\t\tCreateNativeObject (new string [0], new GLib.Value[0]);");
|
||||||
sw.WriteLine ("\t\t\t\treturn;");
|
sw.WriteLine ("\t\t\t\treturn;");
|
||||||
} else {
|
} else {
|
||||||
ArrayList names = new ArrayList ();
|
ArrayList names = new ArrayList ();
|
||||||
ArrayList values = new ArrayList ();
|
ArrayList values = new ArrayList ();
|
||||||
for (int i = 0; i < Parameters.Count; i++) {
|
for (int i = 0; i < Parameters.Count; i++) {
|
||||||
Parameter p = Parameters[i];
|
Parameter p = Parameters[i];
|
||||||
if (container_type.GetPropertyRecursively (p.StudlyName) != null) {
|
if (container_type.GetPropertyRecursively (p.StudlyName) != null) {
|
||||||
names.Add (p.Name);
|
names.Add (p.Name);
|
||||||
values.Add (p.Name);
|
values.Add (p.Name);
|
||||||
} else if (p.PropertyName != String.Empty) {
|
} else if (p.PropertyName != String.Empty) {
|
||||||
names.Add (p.PropertyName);
|
names.Add (p.PropertyName);
|
||||||
values.Add (p.Name);
|
values.Add (p.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (names.Count == Parameters.Count) {
|
if (names.Count == Parameters.Count) {
|
||||||
sw.WriteLine ("\t\t\t\tArrayList vals = new ArrayList();");
|
sw.WriteLine ("\t\t\t\tArrayList vals = new ArrayList();");
|
||||||
sw.WriteLine ("\t\t\t\tArrayList names = new ArrayList();");
|
sw.WriteLine ("\t\t\t\tArrayList names = new ArrayList();");
|
||||||
for (int i = 0; i < names.Count; i++) {
|
for (int i = 0; i < names.Count; i++) {
|
||||||
Parameter p = Parameters [i];
|
Parameter p = Parameters [i];
|
||||||
string indent = "\t\t\t\t";
|
string indent = "\t\t\t\t";
|
||||||
if (p.Generatable is ClassBase && !(p.Generatable is StructBase)) {
|
if (p.Generatable is ClassBase && !(p.Generatable is StructBase)) {
|
||||||
sw.WriteLine (indent + "if (" + p.Name + " != null) {");
|
sw.WriteLine (indent + "if (" + p.Name + " != null) {");
|
||||||
indent += "\t";
|
indent += "\t";
|
||||||
}
|
}
|
||||||
sw.WriteLine (indent + "names.Add (\"" + names [i] + "\");");
|
sw.WriteLine (indent + "names.Add (\"" + names [i] + "\");");
|
||||||
sw.WriteLine (indent + "vals.Add (new GLib.Value (" + values[i] + "));");
|
sw.WriteLine (indent + "vals.Add (new GLib.Value (" + values[i] + "));");
|
||||||
|
|
||||||
if (p.Generatable is ClassBase && !(p.Generatable is StructBase))
|
if (p.Generatable is ClassBase && !(p.Generatable is StructBase))
|
||||||
sw.WriteLine ("\t\t\t\t}");
|
sw.WriteLine ("\t\t\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("\t\t\t\tCreateNativeObject ((string[])names.ToArray (typeof (string)), (GLib.Value[])vals.ToArray (typeof (GLib.Value)));");
|
sw.WriteLine ("\t\t\t\tCreateNativeObject ((string[])names.ToArray (typeof (string)), (GLib.Value[])vals.ToArray (typeof (GLib.Value)));");
|
||||||
sw.WriteLine ("\t\t\t\treturn;");
|
sw.WriteLine ("\t\t\t\treturn;");
|
||||||
} else
|
} else
|
||||||
sw.WriteLine ("\t\t\t\tthrow new InvalidOperationException (\"Can't override this constructor.\");");
|
sw.WriteLine ("\t\t\t\tthrow new InvalidOperationException (\"Can't override this constructor.\");");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Body.Initialize(gen_info, false, false, "");
|
Body.Initialize(gen_info, false, false, "");
|
||||||
sw.WriteLine("\t\t\t{0} = {1}({2});", container_type.AssignToName, CName, Body.GetCallString (false));
|
sw.WriteLine("\t\t\t{0} = {1}({2});", container_type.AssignToName, CName, Body.GetCallString (false));
|
||||||
Body.Finish (sw, "");
|
Body.Finish (sw, "");
|
||||||
Body.HandleException (sw, "");
|
Body.HandleException (sw, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine("\t\t}");
|
sw.WriteLine("\t\t}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
Statistics.CtorCount++;
|
Statistics.CtorCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,133 +1,133 @@
|
|||||||
// GtkSharp.Generation.EnumGen.cs - The Enumeration Generatable.
|
// GtkSharp.Generation.EnumGen.cs - The Enumeration Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001 Mike Kestner
|
// Copyright (c) 2001 Mike Kestner
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
public class EnumGen : GenBase {
|
public class EnumGen : GenBase {
|
||||||
|
|
||||||
string enum_type = String.Empty;
|
string enum_type = String.Empty;
|
||||||
ArrayList members = new ArrayList ();
|
ArrayList members = new ArrayList ();
|
||||||
|
|
||||||
public EnumGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
public EnumGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
||||||
{
|
{
|
||||||
foreach (XmlElement member in elem.ChildNodes) {
|
foreach (XmlElement member in elem.ChildNodes) {
|
||||||
if (member.Name != "member")
|
if (member.Name != "member")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string result = "\t\t" + member.GetAttribute("name");
|
string result = "\t\t" + member.GetAttribute("name");
|
||||||
if (member.HasAttribute ("value")) {
|
if (member.HasAttribute ("value")) {
|
||||||
string value = member.GetAttribute ("value").Trim ();
|
string value = member.GetAttribute ("value").Trim ();
|
||||||
foreach (Match match in Regex.Matches (value, "[0-9]+([UL]{1,2})", RegexOptions.IgnoreCase)) {
|
foreach (Match match in Regex.Matches (value, "[0-9]+([UL]{1,2})", RegexOptions.IgnoreCase)) {
|
||||||
switch (match.Groups[1].Value.ToUpper ()) {
|
switch (match.Groups[1].Value.ToUpper ()) {
|
||||||
case "U": enum_type = " : uint"; break;
|
case "U": enum_type = " : uint"; break;
|
||||||
case "L": enum_type = " : long"; break;
|
case "L": enum_type = " : long"; break;
|
||||||
case "UL": enum_type = " : ulong"; break;
|
case "UL": enum_type = " : ulong"; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result += " = " + value;
|
result += " = " + value;
|
||||||
}
|
}
|
||||||
members.Add (result + ",");
|
members.Add (result + ",");
|
||||||
}
|
}
|
||||||
if (elem.HasAttribute ("enum_type"))
|
if (elem.HasAttribute ("enum_type"))
|
||||||
enum_type = " : " + elem.GetAttribute ("enum_type");
|
enum_type = " : " + elem.GetAttribute ("enum_type");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string DefaultValue {
|
public override string DefaultValue {
|
||||||
get {
|
get {
|
||||||
return "(" + QualifiedName + ") 0";
|
return "(" + QualifiedName + ") 0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return "int";
|
return "int";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var_name)
|
public override string CallByName (string var_name)
|
||||||
{
|
{
|
||||||
return "(int) " + var_name;
|
return "(int) " + var_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative(string var)
|
public override string FromNative(string var)
|
||||||
{
|
{
|
||||||
return "(" + QualifiedName + ") " + var;
|
return "(" + QualifiedName + ") " + var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
StreamWriter sw = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.OpenStream (Name);
|
||||||
|
|
||||||
sw.WriteLine ("namespace " + NS + " {");
|
sw.WriteLine ("namespace " + NS + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
sw.WriteLine ("#region Autogenerated code");
|
sw.WriteLine ("#region Autogenerated code");
|
||||||
|
|
||||||
if (Elem.GetAttribute("type") == "flags")
|
if (Elem.GetAttribute("type") == "flags")
|
||||||
sw.WriteLine ("\t[Flags]");
|
sw.WriteLine ("\t[Flags]");
|
||||||
if (Elem.HasAttribute("gtype"))
|
if (Elem.HasAttribute("gtype"))
|
||||||
sw.WriteLine ("\t[GLib.GType (typeof (" + NS + "." + Name + "GType))]");
|
sw.WriteLine ("\t[GLib.GType (typeof (" + NS + "." + Name + "GType))]");
|
||||||
|
|
||||||
string access = IsInternal ? "internal" : "public";
|
string access = IsInternal ? "internal" : "public";
|
||||||
sw.WriteLine ("\t" + access + " enum " + Name + enum_type + " {");
|
sw.WriteLine ("\t" + access + " enum " + Name + enum_type + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
foreach (string member in members)
|
foreach (string member in members)
|
||||||
sw.WriteLine (member);
|
sw.WriteLine (member);
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
|
|
||||||
if (Elem.HasAttribute ("gtype")) {
|
if (Elem.HasAttribute ("gtype")) {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tinternal class " + Name + "GType {");
|
sw.WriteLine ("\tinternal class " + Name + "GType {");
|
||||||
sw.WriteLine ("\t\t[DllImport (\"" + LibraryName + "\", CallingConvention = CallingConvention.Cdecl)]");
|
sw.WriteLine ("\t\t[DllImport (\"" + LibraryName + "\", CallingConvention = CallingConvention.Cdecl)]");
|
||||||
sw.WriteLine ("\t\tstatic extern IntPtr " + Elem.GetAttribute ("gtype") + " ();");
|
sw.WriteLine ("\t\tstatic extern IntPtr " + Elem.GetAttribute ("gtype") + " ();");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tpublic static GLib.GType GType {");
|
sw.WriteLine ("\t\tpublic static GLib.GType GType {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\treturn new GLib.GType (" + Elem.GetAttribute ("gtype") + " ());");
|
sw.WriteLine ("\t\t\t\treturn new GLib.GType (" + Elem.GetAttribute ("gtype") + " ());");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
Statistics.EnumCount++;
|
Statistics.EnumCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,108 +1,108 @@
|
|||||||
// GtkSharp.Generation.GenBase.cs - The Generatable base class.
|
// GtkSharp.Generation.GenBase.cs - The Generatable base class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2002 Mike Kestner
|
// Copyright (c) 2001-2002 Mike Kestner
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public abstract class GenBase : IGeneratable {
|
public abstract class GenBase : IGeneratable {
|
||||||
|
|
||||||
private XmlElement ns;
|
private XmlElement ns;
|
||||||
private XmlElement elem;
|
private XmlElement elem;
|
||||||
|
|
||||||
protected GenBase (XmlElement ns, XmlElement elem)
|
protected GenBase (XmlElement ns, XmlElement elem)
|
||||||
{
|
{
|
||||||
this.ns = ns;
|
this.ns = ns;
|
||||||
this.elem = elem;
|
this.elem = elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CName {
|
public string CName {
|
||||||
get {
|
get {
|
||||||
return elem.GetAttribute ("cname");
|
return elem.GetAttribute ("cname");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlElement Elem {
|
public XmlElement Elem {
|
||||||
get {
|
get {
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ParserVersion {
|
public int ParserVersion {
|
||||||
get {
|
get {
|
||||||
XmlElement root = elem.OwnerDocument.DocumentElement;
|
XmlElement root = elem.OwnerDocument.DocumentElement;
|
||||||
return root.HasAttribute ("parser_version") ? int.Parse (root.GetAttribute ("parser_version")) : 1;
|
return root.HasAttribute ("parser_version") ? int.Parse (root.GetAttribute ("parser_version")) : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInternal {
|
public bool IsInternal {
|
||||||
get {
|
get {
|
||||||
return elem.GetAttributeAsBoolean ("internal");
|
return elem.GetAttributeAsBoolean ("internal");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LibraryName {
|
public string LibraryName {
|
||||||
get {
|
get {
|
||||||
return ns.GetAttribute ("library");
|
return ns.GetAttribute ("library");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract string MarshalType { get; }
|
public abstract string MarshalType { get; }
|
||||||
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
return elem.GetAttribute ("name");
|
return elem.GetAttribute ("name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string NS {
|
public string NS {
|
||||||
get {
|
get {
|
||||||
return ns.GetAttribute ("name");
|
return ns.GetAttribute ("name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract string DefaultValue { get; }
|
public abstract string DefaultValue { get; }
|
||||||
|
|
||||||
public string QualifiedName {
|
public string QualifiedName {
|
||||||
get {
|
get {
|
||||||
return NS + "." + Name;
|
return NS + "." + Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract string CallByName (string var);
|
public abstract string CallByName (string var);
|
||||||
|
|
||||||
public abstract string FromNative (string var);
|
public abstract string FromNative (string var);
|
||||||
|
|
||||||
public abstract bool Validate ();
|
public abstract bool Validate ();
|
||||||
|
|
||||||
public void Generate ()
|
public void Generate ()
|
||||||
{
|
{
|
||||||
GenerationInfo geninfo = new GenerationInfo (ns);
|
GenerationInfo geninfo = new GenerationInfo (ns);
|
||||||
Generate (geninfo);
|
Generate (geninfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Generate (GenerationInfo geninfo);
|
public abstract void Generate (GenerationInfo geninfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,167 +1,167 @@
|
|||||||
// GtkSharp.Generation.GenerationInfo.cs - Generation information class.
|
// GtkSharp.Generation.GenerationInfo.cs - Generation information class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@ximian.com>
|
// Author: Mike Kestner <mkestner@ximian.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003-2008 Novell Inc.
|
// Copyright (c) 2003-2008 Novell Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class GenerationInfo {
|
public class GenerationInfo {
|
||||||
|
|
||||||
string dir;
|
string dir;
|
||||||
string assembly_name;
|
string assembly_name;
|
||||||
string gluelib_name;
|
string gluelib_name;
|
||||||
bool glue_enabled;
|
bool glue_enabled;
|
||||||
StreamWriter sw;
|
StreamWriter sw;
|
||||||
StreamWriter glue_sw;
|
StreamWriter glue_sw;
|
||||||
|
|
||||||
public GenerationInfo (XmlElement ns)
|
public GenerationInfo (XmlElement ns)
|
||||||
{
|
{
|
||||||
string ns_name = ns.GetAttribute ("name");
|
string ns_name = ns.GetAttribute ("name");
|
||||||
char sep = Path.DirectorySeparatorChar;
|
char sep = Path.DirectorySeparatorChar;
|
||||||
dir = ".." + sep + ns_name.ToLower () + sep + "generated";
|
dir = ".." + sep + ns_name.ToLower () + sep + "generated";
|
||||||
assembly_name = ns_name.ToLower () + "-sharp";
|
assembly_name = ns_name.ToLower () + "-sharp";
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenerationInfo (string dir, string assembly_name) : this (dir, assembly_name, "", "", "") {}
|
public GenerationInfo (string dir, string assembly_name) : this (dir, assembly_name, "", "", "") {}
|
||||||
|
|
||||||
public GenerationInfo (string dir, string assembly_name, string glue_filename, string glue_includes, string gluelib_name)
|
public GenerationInfo (string dir, string assembly_name, string glue_filename, string glue_includes, string gluelib_name)
|
||||||
{
|
{
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
this.assembly_name = assembly_name;
|
this.assembly_name = assembly_name;
|
||||||
this.gluelib_name = gluelib_name;
|
this.gluelib_name = gluelib_name;
|
||||||
InitializeGlue (glue_filename, glue_includes, gluelib_name);
|
InitializeGlue (glue_filename, glue_includes, gluelib_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeGlue (string glue_filename, string glue_includes, string gluelib_name)
|
void InitializeGlue (string glue_filename, string glue_includes, string gluelib_name)
|
||||||
{
|
{
|
||||||
if (gluelib_name != String.Empty && glue_filename != String.Empty) {
|
if (gluelib_name != String.Empty && glue_filename != String.Empty) {
|
||||||
FileStream stream;
|
FileStream stream;
|
||||||
try {
|
try {
|
||||||
stream = new FileStream (glue_filename, FileMode.Create, FileAccess.Write);
|
stream = new FileStream (glue_filename, FileMode.Create, FileAccess.Write);
|
||||||
} catch (Exception) {
|
} catch (Exception) {
|
||||||
Console.Error.WriteLine ("Unable to create specified glue file. Glue will not be generated.");
|
Console.Error.WriteLine ("Unable to create specified glue file. Glue will not be generated.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glue_sw = new StreamWriter (stream);
|
glue_sw = new StreamWriter (stream);
|
||||||
|
|
||||||
glue_sw.WriteLine ("// This file was generated by the Gtk# code generator.");
|
glue_sw.WriteLine ("// This file was generated by the Gtk# code generator.");
|
||||||
glue_sw.WriteLine ("// Any changes made will be lost if regenerated.");
|
glue_sw.WriteLine ("// Any changes made will be lost if regenerated.");
|
||||||
glue_sw.WriteLine ();
|
glue_sw.WriteLine ();
|
||||||
|
|
||||||
if (glue_includes != "") {
|
if (glue_includes != "") {
|
||||||
foreach (string header in glue_includes.Split (new char[] {',', ' '})) {
|
foreach (string header in glue_includes.Split (new char[] {',', ' '})) {
|
||||||
if (header != "")
|
if (header != "")
|
||||||
glue_sw.WriteLine ("#include <{0}>", header);
|
glue_sw.WriteLine ("#include <{0}>", header);
|
||||||
}
|
}
|
||||||
glue_sw.WriteLine ("");
|
glue_sw.WriteLine ("");
|
||||||
}
|
}
|
||||||
glue_enabled = true;
|
glue_enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AssemblyName {
|
public string AssemblyName {
|
||||||
get {
|
get {
|
||||||
return assembly_name;
|
return assembly_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Dir {
|
public string Dir {
|
||||||
get {
|
get {
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GluelibName {
|
public string GluelibName {
|
||||||
get {
|
get {
|
||||||
return gluelib_name;
|
return gluelib_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GlueEnabled {
|
public bool GlueEnabled {
|
||||||
get {
|
get {
|
||||||
return glue_enabled;
|
return glue_enabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamWriter GlueWriter {
|
public StreamWriter GlueWriter {
|
||||||
get {
|
get {
|
||||||
return glue_sw;
|
return glue_sw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamWriter Writer {
|
public StreamWriter Writer {
|
||||||
get {
|
get {
|
||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
sw = value;
|
sw = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloseGlueWriter ()
|
public void CloseGlueWriter ()
|
||||||
{
|
{
|
||||||
if (glue_sw != null)
|
if (glue_sw != null)
|
||||||
glue_sw.Close ();
|
glue_sw.Close ();
|
||||||
}
|
}
|
||||||
|
|
||||||
string member;
|
string member;
|
||||||
public string CurrentMember {
|
public string CurrentMember {
|
||||||
get {
|
get {
|
||||||
return typename + "." + member;
|
return typename + "." + member;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
member = value;
|
member = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string typename;
|
string typename;
|
||||||
public string CurrentType {
|
public string CurrentType {
|
||||||
get {
|
get {
|
||||||
return typename;
|
return typename;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
typename = value;
|
typename = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamWriter OpenStream (string name)
|
public StreamWriter OpenStream (string name)
|
||||||
{
|
{
|
||||||
char sep = Path.DirectorySeparatorChar;
|
char sep = Path.DirectorySeparatorChar;
|
||||||
if (!Directory.Exists(dir))
|
if (!Directory.Exists(dir))
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
string filename = dir + sep + name + ".cs";
|
string filename = dir + sep + name + ".cs";
|
||||||
|
|
||||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
||||||
StreamWriter sw = new StreamWriter (stream);
|
StreamWriter sw = new StreamWriter (stream);
|
||||||
|
|
||||||
sw.WriteLine ("// This file was generated by the Gtk# code generator.");
|
sw.WriteLine ("// This file was generated by the Gtk# code generator.");
|
||||||
sw.WriteLine ("// Any changes made will be lost if regenerated.");
|
sw.WriteLine ("// Any changes made will be lost if regenerated.");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,57 +1,57 @@
|
|||||||
// GtkSharp.Generation.IGeneratable.cs - Interface to generate code for a type.
|
// GtkSharp.Generation.IGeneratable.cs - Interface to generate code for a type.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001 Mike Kestner
|
// Copyright (c) 2001 Mike Kestner
|
||||||
// Copyright (c) 2007 Novell, Inc.
|
// Copyright (c) 2007 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public interface IGeneratable {
|
public interface IGeneratable {
|
||||||
|
|
||||||
// The C name of the generatable
|
// The C name of the generatable
|
||||||
string CName {get;}
|
string CName {get;}
|
||||||
|
|
||||||
// The (short) C# name of the generatable
|
// The (short) C# name of the generatable
|
||||||
string Name {get;}
|
string Name {get;}
|
||||||
|
|
||||||
// The fully-qualified C# name of the generatable
|
// The fully-qualified C# name of the generatable
|
||||||
string QualifiedName {get;}
|
string QualifiedName {get;}
|
||||||
|
|
||||||
// The type (possibly including "ref" or "out") to use in the import
|
// The type (possibly including "ref" or "out") to use in the import
|
||||||
// signature when passing this generatable to unmanaged code
|
// signature when passing this generatable to unmanaged code
|
||||||
string MarshalType {get;}
|
string MarshalType {get;}
|
||||||
|
|
||||||
// The value returned by callbacks that are interrupted prematurely
|
// The value returned by callbacks that are interrupted prematurely
|
||||||
// by managed exceptions or other conditions where an appropriate
|
// by managed exceptions or other conditions where an appropriate
|
||||||
// value can't be otherwise obtained.
|
// value can't be otherwise obtained.
|
||||||
string DefaultValue {get;}
|
string DefaultValue {get;}
|
||||||
|
|
||||||
// Generates an expression to convert var_name to MarshalType
|
// Generates an expression to convert var_name to MarshalType
|
||||||
string CallByName (string var_name);
|
string CallByName (string var_name);
|
||||||
|
|
||||||
// Generates an expression to convert var from MarshalType
|
// Generates an expression to convert var from MarshalType
|
||||||
string FromNative (string var);
|
string FromNative (string var);
|
||||||
|
|
||||||
bool Validate ();
|
bool Validate ();
|
||||||
|
|
||||||
void Generate ();
|
void Generate ();
|
||||||
|
|
||||||
void Generate (GenerationInfo gen_info);
|
void Generate (GenerationInfo gen_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
// GtkSharp.Generation.IManualMarshaler.cs - Interface for manual marshaling.
|
// GtkSharp.Generation.IManualMarshaler.cs - Interface for manual marshaling.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2005 Novell, Inc.
|
// Copyright (c) 2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public interface IManualMarshaler {
|
public interface IManualMarshaler {
|
||||||
|
|
||||||
string AllocNative (string managed_var);
|
string AllocNative (string managed_var);
|
||||||
|
|
||||||
string ReleaseNative (string native_var);
|
string ReleaseNative (string native_var);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,363 +1,363 @@
|
|||||||
// GtkSharp.Generation.InterfaceGen.cs - The Interface Generatable.
|
// GtkSharp.Generation.InterfaceGen.cs - The Interface Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2004, 2007 Novell, Inc.
|
// Copyright (c) 2004, 2007 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class InterfaceGen : ObjectBase {
|
public class InterfaceGen : ObjectBase {
|
||||||
|
|
||||||
bool consume_only;
|
bool consume_only;
|
||||||
|
|
||||||
public InterfaceGen (XmlElement ns, XmlElement elem) : base (ns, elem, true)
|
public InterfaceGen (XmlElement ns, XmlElement elem) : base (ns, elem, true)
|
||||||
{
|
{
|
||||||
consume_only = elem.GetAttributeAsBoolean ("consume_only");
|
consume_only = elem.GetAttributeAsBoolean ("consume_only");
|
||||||
foreach (XmlNode node in elem.ChildNodes) {
|
foreach (XmlNode node in elem.ChildNodes) {
|
||||||
if (!(node is XmlElement)) continue;
|
if (!(node is XmlElement)) continue;
|
||||||
XmlElement member = (XmlElement) node;
|
XmlElement member = (XmlElement) node;
|
||||||
|
|
||||||
switch (member.Name) {
|
switch (member.Name) {
|
||||||
case "signal":
|
case "signal":
|
||||||
object sig = sigs [member.GetAttribute ("name")];
|
object sig = sigs [member.GetAttribute ("name")];
|
||||||
if (sig == null)
|
if (sig == null)
|
||||||
sig = new Signal (node as XmlElement, this);
|
sig = new Signal (node as XmlElement, this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!base.IsNodeNameHandled (node.Name))
|
if (!base.IsNodeNameHandled (node.Name))
|
||||||
new LogWriter (QualifiedName).Warn ("Unexpected node " + node.Name);
|
new LogWriter (QualifiedName).Warn ("Unexpected node " + node.Name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsConsumeOnly {
|
public bool IsConsumeOnly {
|
||||||
get {
|
get {
|
||||||
return consume_only;
|
return consume_only;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var, bool owned)
|
public override string CallByName (string var, bool owned)
|
||||||
{
|
{
|
||||||
return String.Format ("{0} == null ? IntPtr.Zero : (({0} is GLib.Object) ? ({0} as GLib.Object).{1} : ({0} as {2}Adapter).{1})", var, owned ? "OwnedHandle" : "Handle", QualifiedName);
|
return String.Format ("{0} == null ? IntPtr.Zero : (({0} is GLib.Object) ? ({0} as GLib.Object).{1} : ({0} as {2}Adapter).{1})", var, owned ? "OwnedHandle" : "Handle", QualifiedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative (string var, bool owned)
|
public override string FromNative (string var, bool owned)
|
||||||
{
|
{
|
||||||
return QualifiedName + "Adapter.GetObject (" + var + ", " + (owned ? "true" : "false") + ")";
|
return QualifiedName + "Adapter.GetObject (" + var + ", " + (owned ? "true" : "false") + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ValidateForSubclass ()
|
public override bool ValidateForSubclass ()
|
||||||
{
|
{
|
||||||
if (!base.ValidateForSubclass ())
|
if (!base.ValidateForSubclass ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
LogWriter log = new LogWriter (QualifiedName);
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
foreach (Method method in methods.Values) {
|
foreach (Method method in methods.Values) {
|
||||||
if (!method.Validate (log))
|
if (!method.Validate (log))
|
||||||
invalids.Add (method);
|
invalids.Add (method);
|
||||||
}
|
}
|
||||||
foreach (Method method in invalids)
|
foreach (Method method in invalids)
|
||||||
methods.Remove (method.Name);
|
methods.Remove (method.Name);
|
||||||
invalids.Clear ();
|
invalids.Clear ();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateStaticCtor (StreamWriter sw)
|
void GenerateStaticCtor (StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine ("\t\tstatic {0} iface;", class_struct_name);
|
sw.WriteLine ("\t\tstatic {0} iface;", class_struct_name);
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tstatic " + Name + "Adapter ()");
|
sw.WriteLine ("\t\tstatic " + Name + "Adapter ()");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tGLib.GType.Register (_gtype, typeof({0}Adapter));", Name);
|
sw.WriteLine ("\t\t\tGLib.GType.Register (_gtype, typeof({0}Adapter));", Name);
|
||||||
foreach (InterfaceVM vm in interface_vms) {
|
foreach (InterfaceVM vm in interface_vms) {
|
||||||
if (vm.Validate (new LogWriter (QualifiedName)))
|
if (vm.Validate (new LogWriter (QualifiedName)))
|
||||||
sw.WriteLine ("\t\t\tiface.{0} = new {0}NativeDelegate ({0}_cb);", vm.Name);
|
sw.WriteLine ("\t\t\tiface.{0} = new {0}NativeDelegate ({0}_cb);", vm.Name);
|
||||||
}
|
}
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateInitialize (StreamWriter sw)
|
void GenerateInitialize (StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine ("\t\tstatic int class_offset = 2 * IntPtr.Size;"); // Class size of GTypeInterface struct
|
sw.WriteLine ("\t\tstatic int class_offset = 2 * IntPtr.Size;"); // Class size of GTypeInterface struct
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tstatic void Initialize (IntPtr ptr, IntPtr data)");
|
sw.WriteLine ("\t\tstatic void Initialize (IntPtr ptr, IntPtr data)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
if (interface_vms.Count > 0) {
|
if (interface_vms.Count > 0) {
|
||||||
sw.WriteLine ("\t\t\tIntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);");
|
sw.WriteLine ("\t\t\tIntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);");
|
||||||
sw.WriteLine ("\t\t\t{0} native_iface = ({0}) Marshal.PtrToStructure (ifaceptr, typeof ({0}));", class_struct_name);
|
sw.WriteLine ("\t\t\t{0} native_iface = ({0}) Marshal.PtrToStructure (ifaceptr, typeof ({0}));", class_struct_name);
|
||||||
foreach (InterfaceVM vm in interface_vms) {
|
foreach (InterfaceVM vm in interface_vms) {
|
||||||
sw.WriteLine ("\t\t\tnative_iface." + vm.Name + " = iface." + vm.Name + ";");
|
sw.WriteLine ("\t\t\tnative_iface." + vm.Name + " = iface." + vm.Name + ";");
|
||||||
}
|
}
|
||||||
sw.WriteLine ("\t\t\tMarshal.StructureToPtr (native_iface, ifaceptr, false);");
|
sw.WriteLine ("\t\t\tMarshal.StructureToPtr (native_iface, ifaceptr, false);");
|
||||||
sw.WriteLine ("\t\t\tGCHandle gch = (GCHandle) data;");
|
sw.WriteLine ("\t\t\tGCHandle gch = (GCHandle) data;");
|
||||||
sw.WriteLine ("\t\t\tgch.Free ();");
|
sw.WriteLine ("\t\t\tgch.Free ();");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Property prop in props.Values) {
|
foreach (Property prop in props.Values) {
|
||||||
sw.WriteLine ("\t\t\tGLib.Object.OverrideProperty (data, \"" + prop.CName + "\");");
|
sw.WriteLine ("\t\t\tGLib.Object.OverrideProperty (data, \"" + prop.CName + "\");");
|
||||||
}
|
}
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateCallbacks (StreamWriter sw)
|
void GenerateCallbacks (StreamWriter sw)
|
||||||
{
|
{
|
||||||
foreach (InterfaceVM vm in interface_vms) {
|
foreach (InterfaceVM vm in interface_vms) {
|
||||||
vm.GenerateCallback (sw, null);
|
vm.GenerateCallback (sw, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateCtors (StreamWriter sw)
|
void GenerateCtors (StreamWriter sw)
|
||||||
{
|
{
|
||||||
// Native GObjects do not implement the *Implementor interfaces
|
// Native GObjects do not implement the *Implementor interfaces
|
||||||
sw.WriteLine ("\t\tGLib.Object implementor;", Name);
|
sw.WriteLine ("\t\tGLib.Object implementor;", Name);
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
if (!IsConsumeOnly) {
|
if (!IsConsumeOnly) {
|
||||||
sw.WriteLine ("\t\tpublic " + Name + "Adapter ()");
|
sw.WriteLine ("\t\tpublic " + Name + "Adapter ()");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tInitHandler = new GLib.GInterfaceInitHandler (Initialize);");
|
sw.WriteLine ("\t\t\tInitHandler = new GLib.GInterfaceInitHandler (Initialize);");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tpublic {0}Adapter ({0}Implementor implementor)", Name);
|
sw.WriteLine ("\t\tpublic {0}Adapter ({0}Implementor implementor)", Name);
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (implementor == null)");
|
sw.WriteLine ("\t\t\tif (implementor == null)");
|
||||||
sw.WriteLine ("\t\t\t\tthrow new ArgumentNullException (\"implementor\");");
|
sw.WriteLine ("\t\t\t\tthrow new ArgumentNullException (\"implementor\");");
|
||||||
sw.WriteLine ("\t\t\telse if (!(implementor is GLib.Object))");
|
sw.WriteLine ("\t\t\telse if (!(implementor is GLib.Object))");
|
||||||
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"implementor must be a subclass of GLib.Object\");");
|
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"implementor must be a subclass of GLib.Object\");");
|
||||||
sw.WriteLine ("\t\t\tthis.implementor = implementor as GLib.Object;");
|
sw.WriteLine ("\t\t\tthis.implementor = implementor as GLib.Object;");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("\t\tpublic " + Name + "Adapter (IntPtr handle)");
|
sw.WriteLine ("\t\tpublic " + Name + "Adapter (IntPtr handle)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (!_gtype.IsInstance (handle))");
|
sw.WriteLine ("\t\t\tif (!_gtype.IsInstance (handle))");
|
||||||
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"The gobject doesn't implement the GInterface of this adapter\", \"handle\");");
|
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"The gobject doesn't implement the GInterface of this adapter\", \"handle\");");
|
||||||
sw.WriteLine ("\t\t\timplementor = GLib.Object.GetObject (handle);");
|
sw.WriteLine ("\t\t\timplementor = GLib.Object.GetObject (handle);");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateGType (StreamWriter sw)
|
void GenerateGType (StreamWriter sw)
|
||||||
{
|
{
|
||||||
Method m = GetMethod ("GetType");
|
Method m = GetMethod ("GetType");
|
||||||
if (m == null)
|
if (m == null)
|
||||||
throw new Exception ("Interface " + QualifiedName + " missing GetType method.");
|
throw new Exception ("Interface " + QualifiedName + " missing GetType method.");
|
||||||
m.GenerateImport (sw);
|
m.GenerateImport (sw);
|
||||||
sw.WriteLine ("\t\tprivate static GLib.GType _gtype = new GLib.GType ({0} ());", m.CName);
|
sw.WriteLine ("\t\tprivate static GLib.GType _gtype = new GLib.GType ({0} ());", m.CName);
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tpublic override GLib.GType GType {");
|
sw.WriteLine ("\t\tpublic override GLib.GType GType {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\treturn _gtype;");
|
sw.WriteLine ("\t\t\t\treturn _gtype;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateHandleProp (StreamWriter sw)
|
void GenerateHandleProp (StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine ("\t\tpublic override IntPtr Handle {");
|
sw.WriteLine ("\t\tpublic override IntPtr Handle {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\treturn implementor.Handle;");
|
sw.WriteLine ("\t\t\t\treturn implementor.Handle;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tpublic IntPtr OwnedHandle {");
|
sw.WriteLine ("\t\tpublic IntPtr OwnedHandle {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\treturn implementor.OwnedHandle;");
|
sw.WriteLine ("\t\t\t\treturn implementor.OwnedHandle;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateGetObject (StreamWriter sw)
|
void GenerateGetObject (StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine ("\t\tpublic static " + Name + " GetObject (IntPtr handle, bool owned)");
|
sw.WriteLine ("\t\tpublic static " + Name + " GetObject (IntPtr handle, bool owned)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tGLib.Object obj = GLib.Object.GetObject (handle, owned);");
|
sw.WriteLine ("\t\t\tGLib.Object obj = GLib.Object.GetObject (handle, owned);");
|
||||||
sw.WriteLine ("\t\t\treturn GetObject (obj);");
|
sw.WriteLine ("\t\t\treturn GetObject (obj);");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tpublic static " + Name + " GetObject (GLib.Object obj)");
|
sw.WriteLine ("\t\tpublic static " + Name + " GetObject (GLib.Object obj)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (obj == null)");
|
sw.WriteLine ("\t\t\tif (obj == null)");
|
||||||
sw.WriteLine ("\t\t\t\treturn null;");
|
sw.WriteLine ("\t\t\t\treturn null;");
|
||||||
if (!IsConsumeOnly) {
|
if (!IsConsumeOnly) {
|
||||||
sw.WriteLine ("\t\t\telse if (obj is " + Name + "Implementor)");
|
sw.WriteLine ("\t\t\telse if (obj is " + Name + "Implementor)");
|
||||||
sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj as {0}Implementor);", Name);
|
sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj as {0}Implementor);", Name);
|
||||||
}
|
}
|
||||||
sw.WriteLine ("\t\t\telse if (obj as " + Name + " == null)");
|
sw.WriteLine ("\t\t\telse if (obj as " + Name + " == null)");
|
||||||
sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj.Handle);", Name);
|
sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj.Handle);", Name);
|
||||||
sw.WriteLine ("\t\t\telse");
|
sw.WriteLine ("\t\t\telse");
|
||||||
sw.WriteLine ("\t\t\t\treturn obj as {0};", Name);
|
sw.WriteLine ("\t\t\t\treturn obj as {0};", Name);
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateImplementorProp (StreamWriter sw)
|
void GenerateImplementorProp (StreamWriter sw)
|
||||||
{
|
{
|
||||||
sw.WriteLine ("\t\tpublic " + Name + "Implementor Implementor {");
|
sw.WriteLine ("\t\tpublic " + Name + "Implementor Implementor {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\treturn implementor as {0}Implementor;", Name);
|
sw.WriteLine ("\t\t\t\treturn implementor as {0}Implementor;", Name);
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateAdapter (GenerationInfo gen_info)
|
void GenerateAdapter (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name + "Adapter");
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name + "Adapter");
|
||||||
|
|
||||||
sw.WriteLine ("namespace " + NS + " {");
|
sw.WriteLine ("namespace " + NS + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("#region Autogenerated code");
|
sw.WriteLine ("#region Autogenerated code");
|
||||||
sw.WriteLine ("\tpublic partial class " + Name + "Adapter : GLib.GInterfaceAdapter, " + QualifiedName + " {");
|
sw.WriteLine ("\tpublic partial class " + Name + "Adapter : GLib.GInterfaceAdapter, " + QualifiedName + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
if (!IsConsumeOnly) {
|
if (!IsConsumeOnly) {
|
||||||
GenerateClassStruct (gen_info);
|
GenerateClassStruct (gen_info);
|
||||||
GenerateStaticCtor (sw);
|
GenerateStaticCtor (sw);
|
||||||
GenerateCallbacks (sw);
|
GenerateCallbacks (sw);
|
||||||
GenerateInitialize (sw);
|
GenerateInitialize (sw);
|
||||||
}
|
}
|
||||||
GenerateCtors (sw);
|
GenerateCtors (sw);
|
||||||
GenerateGType (sw);
|
GenerateGType (sw);
|
||||||
GenerateHandleProp (sw);
|
GenerateHandleProp (sw);
|
||||||
GenerateGetObject (sw);
|
GenerateGetObject (sw);
|
||||||
if (!IsConsumeOnly)
|
if (!IsConsumeOnly)
|
||||||
GenerateImplementorProp (sw);
|
GenerateImplementorProp (sw);
|
||||||
|
|
||||||
GenProperties (gen_info, null);
|
GenProperties (gen_info, null);
|
||||||
|
|
||||||
foreach (Signal sig in sigs.Values)
|
foreach (Signal sig in sigs.Values)
|
||||||
sig.GenEvent (sw, null, "GLib.Object.GetObject (Handle)");
|
sig.GenEvent (sw, null, "GLib.Object.GetObject (Handle)");
|
||||||
|
|
||||||
Method temp = methods ["GetType"] as Method;
|
Method temp = methods ["GetType"] as Method;
|
||||||
if (temp != null)
|
if (temp != null)
|
||||||
methods.Remove ("GetType");
|
methods.Remove ("GetType");
|
||||||
GenMethods (gen_info, new Hashtable (), this);
|
GenMethods (gen_info, new Hashtable (), this);
|
||||||
if (temp != null)
|
if (temp != null)
|
||||||
methods ["GetType"] = temp;
|
methods ["GetType"] = temp;
|
||||||
|
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
gen_info.Writer = null;
|
gen_info.Writer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateImplementorIface (GenerationInfo gen_info)
|
void GenerateImplementorIface (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
if (IsConsumeOnly)
|
if (IsConsumeOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t[GLib.GInterface (typeof (" + Name + "Adapter))]");
|
sw.WriteLine ("\t[GLib.GInterface (typeof (" + Name + "Adapter))]");
|
||||||
string access = IsInternal ? "internal" : "public";
|
string access = IsInternal ? "internal" : "public";
|
||||||
sw.WriteLine ("\t" + access + " partial interface " + Name + "Implementor : GLib.IWrapper {");
|
sw.WriteLine ("\t" + access + " partial interface " + Name + "Implementor : GLib.IWrapper {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
Hashtable vm_table = new Hashtable ();
|
Hashtable vm_table = new Hashtable ();
|
||||||
foreach (InterfaceVM vm in interface_vms) {
|
foreach (InterfaceVM vm in interface_vms) {
|
||||||
vm_table [vm.Name] = vm;
|
vm_table [vm.Name] = vm;
|
||||||
}
|
}
|
||||||
foreach (InterfaceVM vm in interface_vms) {
|
foreach (InterfaceVM vm in interface_vms) {
|
||||||
if (vm_table [vm.Name] == null)
|
if (vm_table [vm.Name] == null)
|
||||||
continue;
|
continue;
|
||||||
else if (!vm.Validate (new LogWriter (QualifiedName))) {
|
else if (!vm.Validate (new LogWriter (QualifiedName))) {
|
||||||
vm_table.Remove (vm.Name);
|
vm_table.Remove (vm.Name);
|
||||||
continue;
|
continue;
|
||||||
} else if (vm.IsGetter || vm.IsSetter) {
|
} else if (vm.IsGetter || vm.IsSetter) {
|
||||||
string cmp_name = (vm.IsGetter ? "Set" : "Get") + vm.Name.Substring (3);
|
string cmp_name = (vm.IsGetter ? "Set" : "Get") + vm.Name.Substring (3);
|
||||||
InterfaceVM cmp = vm_table [cmp_name] as InterfaceVM;
|
InterfaceVM cmp = vm_table [cmp_name] as InterfaceVM;
|
||||||
if (cmp != null && (cmp.IsGetter || cmp.IsSetter)) {
|
if (cmp != null && (cmp.IsGetter || cmp.IsSetter)) {
|
||||||
if (vm.IsSetter)
|
if (vm.IsSetter)
|
||||||
cmp.GenerateDeclaration (sw, vm);
|
cmp.GenerateDeclaration (sw, vm);
|
||||||
else
|
else
|
||||||
vm.GenerateDeclaration (sw, cmp);
|
vm.GenerateDeclaration (sw, cmp);
|
||||||
vm_table.Remove (cmp.Name);
|
vm_table.Remove (cmp.Name);
|
||||||
} else
|
} else
|
||||||
vm.GenerateDeclaration (sw, null);
|
vm.GenerateDeclaration (sw, null);
|
||||||
vm_table.Remove (vm.Name);
|
vm_table.Remove (vm.Name);
|
||||||
} else {
|
} else {
|
||||||
vm.GenerateDeclaration (sw, null);
|
vm.GenerateDeclaration (sw, null);
|
||||||
vm_table.Remove (vm.Name);
|
vm_table.Remove (vm.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (Property prop in props.Values) {
|
foreach (Property prop in props.Values) {
|
||||||
sw.WriteLine ("\t\t[GLib.Property (\"" + prop.CName + "\")]");
|
sw.WriteLine ("\t\t[GLib.Property (\"" + prop.CName + "\")]");
|
||||||
prop.GenerateDecl (sw, "\t\t");
|
prop.GenerateDecl (sw, "\t\t");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
GenerateAdapter (gen_info);
|
GenerateAdapter (gen_info);
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||||
|
|
||||||
sw.WriteLine ("namespace " + NS + " {");
|
sw.WriteLine ("namespace " + NS + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("#region Autogenerated code");
|
sw.WriteLine ("#region Autogenerated code");
|
||||||
string access = IsInternal ? "internal" : "public";
|
string access = IsInternal ? "internal" : "public";
|
||||||
sw.WriteLine ("\t" + access + " partial interface " + Name + " : GLib.IWrapper {");
|
sw.WriteLine ("\t" + access + " partial interface " + Name + " : GLib.IWrapper {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
foreach (Signal sig in sigs.Values) {
|
foreach (Signal sig in sigs.Values) {
|
||||||
sig.GenerateDecl (sw);
|
sig.GenerateDecl (sw);
|
||||||
sig.GenEventHandler (gen_info);
|
sig.GenEventHandler (gen_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Method method in methods.Values) {
|
foreach (Method method in methods.Values) {
|
||||||
if (IgnoreMethod (method, this))
|
if (IgnoreMethod (method, this))
|
||||||
continue;
|
continue;
|
||||||
method.GenerateDecl (sw);
|
method.GenerateDecl (sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Property prop in props.Values)
|
foreach (Property prop in props.Values)
|
||||||
prop.GenerateDecl (sw, "\t\t");
|
prop.GenerateDecl (sw, "\t\t");
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
GenerateImplementorIface (gen_info);
|
GenerateImplementorIface (gen_info);
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
gen_info.Writer = null;
|
gen_info.Writer = null;
|
||||||
Statistics.IFaceCount++;
|
Statistics.IFaceCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,58 +1,58 @@
|
|||||||
// GtkSharp.Generation.LPGen.cs - long/pointer Generatable.
|
// GtkSharp.Generation.LPGen.cs - long/pointer Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
public class LPGen : SimpleGen, IAccessor {
|
public class LPGen : SimpleGen, IAccessor {
|
||||||
|
|
||||||
public LPGen (string ctype) : base (ctype, "long", "0L") {}
|
public LPGen (string ctype) : base (ctype, "long", "0L") {}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return "IntPtr";
|
return "IntPtr";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var_name)
|
public override string CallByName (string var_name)
|
||||||
{
|
{
|
||||||
return "new IntPtr (" + var_name + ")";
|
return "new IntPtr (" + var_name + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative(string var)
|
public override string FromNative(string var)
|
||||||
{
|
{
|
||||||
return "(long) " + var;
|
return "(long) " + var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteAccessors (StreamWriter sw, string indent, string var)
|
public void WriteAccessors (StreamWriter sw, string indent, string var)
|
||||||
{
|
{
|
||||||
sw.WriteLine (indent + "get {");
|
sw.WriteLine (indent + "get {");
|
||||||
sw.WriteLine (indent + "\treturn " + FromNative (var) + ";");
|
sw.WriteLine (indent + "\treturn " + FromNative (var) + ";");
|
||||||
sw.WriteLine (indent + "}");
|
sw.WriteLine (indent + "}");
|
||||||
sw.WriteLine (indent + "set {");
|
sw.WriteLine (indent + "set {");
|
||||||
sw.WriteLine (indent + "\t" + var + " = " + CallByName ("value") + ";");
|
sw.WriteLine (indent + "\t" + var + " = " + CallByName ("value") + ";");
|
||||||
sw.WriteLine (indent + "}");
|
sw.WriteLine (indent + "}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,58 +1,58 @@
|
|||||||
// GtkSharp.Generation.LPUGen.cs - unsugned long/pointer generatable.
|
// GtkSharp.Generation.LPUGen.cs - unsugned long/pointer generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
public class LPUGen : SimpleGen, IAccessor {
|
public class LPUGen : SimpleGen, IAccessor {
|
||||||
|
|
||||||
public LPUGen (string ctype) : base (ctype, "ulong", "0") {}
|
public LPUGen (string ctype) : base (ctype, "ulong", "0") {}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return "UIntPtr";
|
return "UIntPtr";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var_name)
|
public override string CallByName (string var_name)
|
||||||
{
|
{
|
||||||
return "new UIntPtr (" + var_name + ")";
|
return "new UIntPtr (" + var_name + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative(string var)
|
public override string FromNative(string var)
|
||||||
{
|
{
|
||||||
return "(ulong) " + var;
|
return "(ulong) " + var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteAccessors (StreamWriter sw, string indent, string var)
|
public void WriteAccessors (StreamWriter sw, string indent, string var)
|
||||||
{
|
{
|
||||||
sw.WriteLine (indent + "get {");
|
sw.WriteLine (indent + "get {");
|
||||||
sw.WriteLine (indent + "\treturn " + FromNative (var) + ";");
|
sw.WriteLine (indent + "\treturn " + FromNative (var) + ";");
|
||||||
sw.WriteLine (indent + "}");
|
sw.WriteLine (indent + "}");
|
||||||
sw.WriteLine (indent + "set {");
|
sw.WriteLine (indent + "set {");
|
||||||
sw.WriteLine (indent + "\t" + var + " = " + CallByName ("value") + ";");
|
sw.WriteLine (indent + "\t" + var + " = " + CallByName ("value") + ";");
|
||||||
sw.WriteLine (indent + "}");
|
sw.WriteLine (indent + "}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,58 +1,58 @@
|
|||||||
// GtkSharp.Generation.ManualGen.cs - Ungenerated handle type Generatable.
|
// GtkSharp.Generation.ManualGen.cs - Ungenerated handle type Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003 Mike Kestner
|
// Copyright (c) 2003 Mike Kestner
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class ManualGen : SimpleBase {
|
public class ManualGen : SimpleBase {
|
||||||
|
|
||||||
string from_fmt;
|
string from_fmt;
|
||||||
|
|
||||||
public ManualGen (string ctype, string type) : base (ctype, type, "null")
|
public ManualGen (string ctype, string type) : base (ctype, type, "null")
|
||||||
{
|
{
|
||||||
from_fmt = "new " + QualifiedName + "({0})";
|
from_fmt = "new " + QualifiedName + "({0})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualGen (string ctype, string type, string from_fmt) : base (ctype, type, "null")
|
public ManualGen (string ctype, string type, string from_fmt) : base (ctype, type, "null")
|
||||||
{
|
{
|
||||||
this.from_fmt = from_fmt;
|
this.from_fmt = from_fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return "IntPtr";
|
return "IntPtr";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var_name)
|
public override string CallByName (string var_name)
|
||||||
{
|
{
|
||||||
return var_name + " == null ? IntPtr.Zero : " + var_name + ".Handle";
|
return var_name + " == null ? IntPtr.Zero : " + var_name + ".Handle";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative(string var)
|
public override string FromNative(string var)
|
||||||
{
|
{
|
||||||
return String.Format (from_fmt, var);
|
return String.Format (from_fmt, var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,334 +1,334 @@
|
|||||||
// GtkSharp.Generation.Method.cs - The Method Generatable.
|
// GtkSharp.Generation.Method.cs - The Method Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2003-2004 Novell, Inc.
|
// Copyright (c) 2003-2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class Method : MethodBase {
|
public class Method : MethodBase {
|
||||||
|
|
||||||
private ReturnValue retval;
|
private ReturnValue retval;
|
||||||
|
|
||||||
private string call;
|
private string call;
|
||||||
private bool is_get, is_set;
|
private bool is_get, is_set;
|
||||||
private bool deprecated = false;
|
private bool deprecated = false;
|
||||||
private bool win32_utf8_variant = false;
|
private bool win32_utf8_variant = false;
|
||||||
|
|
||||||
public Method (XmlElement elem, ClassBase container_type) : base (elem, container_type)
|
public Method (XmlElement elem, ClassBase container_type) : base (elem, container_type)
|
||||||
{
|
{
|
||||||
this.retval = new ReturnValue (elem["return-type"]);
|
this.retval = new ReturnValue (elem["return-type"]);
|
||||||
|
|
||||||
if (!container_type.IsDeprecated) {
|
if (!container_type.IsDeprecated) {
|
||||||
deprecated = elem.GetAttributeAsBoolean ("deprecated");
|
deprecated = elem.GetAttributeAsBoolean ("deprecated");
|
||||||
}
|
}
|
||||||
|
|
||||||
win32_utf8_variant = elem.GetAttributeAsBoolean ("win32_utf8_variant");
|
win32_utf8_variant = elem.GetAttributeAsBoolean ("win32_utf8_variant");
|
||||||
|
|
||||||
if (Name == "GetType")
|
if (Name == "GetType")
|
||||||
Name = "GetGType";
|
Name = "GetGType";
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasWin32Utf8Variant {
|
public bool HasWin32Utf8Variant {
|
||||||
get { return win32_utf8_variant; }
|
get { return win32_utf8_variant; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDeprecated {
|
public bool IsDeprecated {
|
||||||
get {
|
get {
|
||||||
return deprecated;
|
return deprecated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsGetter {
|
public bool IsGetter {
|
||||||
get {
|
get {
|
||||||
return is_get;
|
return is_get;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSetter {
|
public bool IsSetter {
|
||||||
get {
|
get {
|
||||||
return is_set;
|
return is_set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReturnType {
|
public string ReturnType {
|
||||||
get {
|
get {
|
||||||
return retval.CSType;
|
return retval.CSType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Validate (LogWriter log)
|
public override bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
log.Member = Name;
|
log.Member = Name;
|
||||||
if (!retval.Validate (log) || !base.Validate (log))
|
if (!retval.Validate (log) || !base.Validate (log))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Parameters parms = Parameters;
|
Parameters parms = Parameters;
|
||||||
is_get = ((((parms.IsAccessor && retval.IsVoid) || (parms.Count == 0 && !retval.IsVoid)) || (parms.Count == 0 && !retval.IsVoid)) && HasGetterName);
|
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);
|
is_set = ((parms.IsAccessor || (parms.VisibleCount == 1 && retval.IsVoid)) && HasSetterName);
|
||||||
|
|
||||||
call = "(" + (IsStatic ? "" : container_type.CallByName () + (parms.Count > 0 ? ", " : "")) + Body.GetCallString (is_set) + ")";
|
call = "(" + (IsStatic ? "" : container_type.CallByName () + (parms.Count > 0 ? ", " : "")) + Body.GetCallString (is_set) + ")";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Method GetComplement ()
|
private Method GetComplement ()
|
||||||
{
|
{
|
||||||
char complement;
|
char complement;
|
||||||
if (is_get)
|
if (is_get)
|
||||||
complement = 'S';
|
complement = 'S';
|
||||||
else
|
else
|
||||||
complement = 'G';
|
complement = 'G';
|
||||||
|
|
||||||
return container_type.GetMethod (complement + BaseName.Substring (1));
|
return container_type.GetMethod (complement + BaseName.Substring (1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Declaration {
|
public string Declaration {
|
||||||
get {
|
get {
|
||||||
return retval.CSType + " " + Name + " (" + (Signature != null ? Signature.ToString() : "") + ");";
|
return retval.CSType + " " + Name + " (" + (Signature != null ? Signature.ToString() : "") + ");";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateDeclCommon (StreamWriter sw, ClassBase implementor)
|
private void GenerateDeclCommon (StreamWriter sw, ClassBase implementor)
|
||||||
{
|
{
|
||||||
if (IsStatic)
|
if (IsStatic)
|
||||||
sw.Write("static ");
|
sw.Write("static ");
|
||||||
sw.Write (Safety);
|
sw.Write (Safety);
|
||||||
Method dup = null;
|
Method dup = null;
|
||||||
if (container_type != null)
|
if (container_type != null)
|
||||||
dup = container_type.GetMethodRecursively (Name);
|
dup = container_type.GetMethodRecursively (Name);
|
||||||
if (implementor != null)
|
if (implementor != null)
|
||||||
dup = implementor.GetMethodRecursively (Name);
|
dup = implementor.GetMethodRecursively (Name);
|
||||||
|
|
||||||
if (Name == "ToString" && Parameters.Count == 0 && (!(container_type is InterfaceGen)|| implementor != null))
|
if (Name == "ToString" && Parameters.Count == 0 && (!(container_type is InterfaceGen)|| implementor != null))
|
||||||
sw.Write("override ");
|
sw.Write("override ");
|
||||||
else if (Name == "GetGType" && container_type is ObjectGen)
|
else if (Name == "GetGType" && container_type is ObjectGen)
|
||||||
sw.Write("new ");
|
sw.Write("new ");
|
||||||
else if (Modifiers == "new " || (dup != null && ((dup.Signature != null && Signature != null && dup.Signature.ToString() == Signature.ToString()) || (dup.Signature == null && Signature == null))))
|
else if (Modifiers == "new " || (dup != null && ((dup.Signature != null && Signature != null && dup.Signature.ToString() == Signature.ToString()) || (dup.Signature == null && Signature == null))))
|
||||||
sw.Write("new ");
|
sw.Write("new ");
|
||||||
|
|
||||||
if (is_get || is_set) {
|
if (is_get || is_set) {
|
||||||
if (retval.IsVoid)
|
if (retval.IsVoid)
|
||||||
sw.Write (Parameters.AccessorReturnType);
|
sw.Write (Parameters.AccessorReturnType);
|
||||||
else
|
else
|
||||||
sw.Write(retval.CSType);
|
sw.Write(retval.CSType);
|
||||||
sw.Write(" ");
|
sw.Write(" ");
|
||||||
if (Name.StartsWith ("Get") || Name.StartsWith ("Set"))
|
if (Name.StartsWith ("Get") || Name.StartsWith ("Set"))
|
||||||
sw.Write (Name.Substring (3));
|
sw.Write (Name.Substring (3));
|
||||||
else {
|
else {
|
||||||
int dot = Name.LastIndexOf ('.');
|
int dot = Name.LastIndexOf ('.');
|
||||||
if (dot != -1 && (Name.Substring (dot + 1, 3) == "Get" || Name.Substring (dot + 1, 3) == "Set"))
|
if (dot != -1 && (Name.Substring (dot + 1, 3) == "Get" || Name.Substring (dot + 1, 3) == "Set"))
|
||||||
sw.Write (Name.Substring (0, dot + 1) + Name.Substring (dot + 4));
|
sw.Write (Name.Substring (0, dot + 1) + Name.Substring (dot + 4));
|
||||||
else
|
else
|
||||||
sw.Write (Name);
|
sw.Write (Name);
|
||||||
}
|
}
|
||||||
sw.WriteLine(" { ");
|
sw.WriteLine(" { ");
|
||||||
} else if (IsAccessor) {
|
} else if (IsAccessor) {
|
||||||
sw.Write (Signature.AccessorType + " " + Name + "(" + Signature.AsAccessor + ")");
|
sw.Write (Signature.AccessorType + " " + Name + "(" + Signature.AsAccessor + ")");
|
||||||
} else {
|
} else {
|
||||||
sw.Write(retval.CSType + " " + Name + "(" + (Signature != null ? Signature.ToString() : "") + ")");
|
sw.Write(retval.CSType + " " + Name + "(" + (Signature != null ? Signature.ToString() : "") + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateDecl (StreamWriter sw)
|
public void GenerateDecl (StreamWriter sw)
|
||||||
{
|
{
|
||||||
if (IsStatic)
|
if (IsStatic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (is_get || is_set)
|
if (is_get || is_set)
|
||||||
{
|
{
|
||||||
Method comp = GetComplement ();
|
Method comp = GetComplement ();
|
||||||
if (comp != null && is_set)
|
if (comp != null && is_set)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sw.Write("\t\t");
|
sw.Write("\t\t");
|
||||||
GenerateDeclCommon (sw, null);
|
GenerateDeclCommon (sw, null);
|
||||||
|
|
||||||
sw.Write("\t\t\t");
|
sw.Write("\t\t\t");
|
||||||
sw.Write ((is_get) ? "get;" : "set;");
|
sw.Write ((is_get) ? "get;" : "set;");
|
||||||
|
|
||||||
if (comp != null && comp.is_set)
|
if (comp != null && comp.is_set)
|
||||||
sw.WriteLine (" set;");
|
sw.WriteLine (" set;");
|
||||||
else
|
else
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sw.Write("\t\t");
|
sw.Write("\t\t");
|
||||||
GenerateDeclCommon (sw, null);
|
GenerateDeclCommon (sw, null);
|
||||||
sw.WriteLine (";");
|
sw.WriteLine (";");
|
||||||
}
|
}
|
||||||
|
|
||||||
Statistics.MethodCount++;
|
Statistics.MethodCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateImport (StreamWriter sw)
|
public void GenerateImport (StreamWriter sw)
|
||||||
{
|
{
|
||||||
string import_sig = IsStatic ? "" : container_type.MarshalType + " raw";
|
string import_sig = IsStatic ? "" : container_type.MarshalType + " raw";
|
||||||
import_sig += !IsStatic && Parameters.Count > 0 ? ", " : "";
|
import_sig += !IsStatic && Parameters.Count > 0 ? ", " : "";
|
||||||
import_sig += Parameters.ImportSignature.ToString();
|
import_sig += Parameters.ImportSignature.ToString();
|
||||||
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\", CallingConvention = CallingConvention.Cdecl)]");
|
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\", CallingConvention = CallingConvention.Cdecl)]");
|
||||||
if (retval.MarshalType.StartsWith ("[return:"))
|
if (retval.MarshalType.StartsWith ("[return:"))
|
||||||
sw.WriteLine("\t\t" + retval.MarshalType + " static extern " + Safety + retval.CSType + " " + CName + "(" + import_sig + ");");
|
sw.WriteLine("\t\t" + retval.MarshalType + " static extern " + Safety + retval.CSType + " " + CName + "(" + import_sig + ");");
|
||||||
else
|
else
|
||||||
sw.WriteLine("\t\tstatic extern " + Safety + retval.MarshalType + " " + CName + "(" + import_sig + ");");
|
sw.WriteLine("\t\tstatic extern " + Safety + retval.MarshalType + " " + CName + "(" + import_sig + ");");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
if (HasWin32Utf8Variant) {
|
if (HasWin32Utf8Variant) {
|
||||||
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
|
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
|
||||||
if (retval.MarshalType.StartsWith ("[return:"))
|
if (retval.MarshalType.StartsWith ("[return:"))
|
||||||
sw.WriteLine("\t\t" + retval.MarshalType + " static extern " + Safety + retval.CSType + " " + CName + "_utf8(" + import_sig + ");");
|
sw.WriteLine("\t\t" + retval.MarshalType + " static extern " + Safety + retval.CSType + " " + CName + "_utf8(" + import_sig + ");");
|
||||||
else
|
else
|
||||||
sw.WriteLine("\t\tstatic extern " + Safety + retval.MarshalType + " " + CName + "_utf8(" + import_sig + ");");
|
sw.WriteLine("\t\tstatic extern " + Safety + retval.MarshalType + " " + CName + "_utf8(" + import_sig + ");");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
||||||
{
|
{
|
||||||
Method comp = null;
|
Method comp = null;
|
||||||
|
|
||||||
gen_info.CurrentMember = Name;
|
gen_info.CurrentMember = Name;
|
||||||
|
|
||||||
/* we are generated by the get Method, if there is one */
|
/* we are generated by the get Method, if there is one */
|
||||||
if (is_set || is_get)
|
if (is_set || is_get)
|
||||||
{
|
{
|
||||||
if (Modifiers != "new " && container_type.GetPropertyRecursively (Name.Substring (3)) != null)
|
if (Modifiers != "new " && container_type.GetPropertyRecursively (Name.Substring (3)) != null)
|
||||||
return;
|
return;
|
||||||
comp = GetComplement ();
|
comp = GetComplement ();
|
||||||
if (comp != null && is_set) {
|
if (comp != null && is_set) {
|
||||||
if (Parameters.AccessorReturnType == comp.ReturnType)
|
if (Parameters.AccessorReturnType == comp.ReturnType)
|
||||||
return;
|
return;
|
||||||
else {
|
else {
|
||||||
is_set = false;
|
is_set = false;
|
||||||
call = "(Handle, " + Body.GetCallString (false) + ")";
|
call = "(Handle, " + Body.GetCallString (false) + ")";
|
||||||
comp = null;
|
comp = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* some setters take more than one arg */
|
/* some setters take more than one arg */
|
||||||
if (comp != null && !comp.is_set)
|
if (comp != null && !comp.is_set)
|
||||||
comp = null;
|
comp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateImport (gen_info.Writer);
|
GenerateImport (gen_info.Writer);
|
||||||
if (comp != null && retval.CSType == comp.Parameters.AccessorReturnType)
|
if (comp != null && retval.CSType == comp.Parameters.AccessorReturnType)
|
||||||
comp.GenerateImport (gen_info.Writer);
|
comp.GenerateImport (gen_info.Writer);
|
||||||
|
|
||||||
if (IsDeprecated)
|
if (IsDeprecated)
|
||||||
gen_info.Writer.WriteLine("\t\t[Obsolete]");
|
gen_info.Writer.WriteLine("\t\t[Obsolete]");
|
||||||
gen_info.Writer.Write("\t\t");
|
gen_info.Writer.Write("\t\t");
|
||||||
if (Protection != "")
|
if (Protection != "")
|
||||||
gen_info.Writer.Write("{0} ", Protection);
|
gen_info.Writer.Write("{0} ", Protection);
|
||||||
GenerateDeclCommon (gen_info.Writer, implementor);
|
GenerateDeclCommon (gen_info.Writer, implementor);
|
||||||
|
|
||||||
if (is_get || is_set)
|
if (is_get || is_set)
|
||||||
{
|
{
|
||||||
gen_info.Writer.Write ("\t\t\t");
|
gen_info.Writer.Write ("\t\t\t");
|
||||||
gen_info.Writer.Write ((is_get) ? "get" : "set");
|
gen_info.Writer.Write ((is_get) ? "get" : "set");
|
||||||
GenerateBody (gen_info, implementor, "\t");
|
GenerateBody (gen_info, implementor, "\t");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
GenerateBody (gen_info, implementor, "");
|
GenerateBody (gen_info, implementor, "");
|
||||||
|
|
||||||
if (is_get || is_set)
|
if (is_get || is_set)
|
||||||
{
|
{
|
||||||
if (comp != null && retval.CSType == comp.Parameters.AccessorReturnType)
|
if (comp != null && retval.CSType == comp.Parameters.AccessorReturnType)
|
||||||
{
|
{
|
||||||
gen_info.Writer.WriteLine ();
|
gen_info.Writer.WriteLine ();
|
||||||
gen_info.Writer.Write ("\t\t\tset");
|
gen_info.Writer.Write ("\t\t\tset");
|
||||||
comp.GenerateBody (gen_info, implementor, "\t");
|
comp.GenerateBody (gen_info, implementor, "\t");
|
||||||
}
|
}
|
||||||
gen_info.Writer.WriteLine ();
|
gen_info.Writer.WriteLine ();
|
||||||
gen_info.Writer.WriteLine ("\t\t}");
|
gen_info.Writer.WriteLine ("\t\t}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gen_info.Writer.WriteLine();
|
gen_info.Writer.WriteLine();
|
||||||
|
|
||||||
gen_info.Writer.WriteLine();
|
gen_info.Writer.WriteLine();
|
||||||
|
|
||||||
Statistics.MethodCount++;
|
Statistics.MethodCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateBody (GenerationInfo gen_info, ClassBase implementor, string indent)
|
public void GenerateBody (GenerationInfo gen_info, ClassBase implementor, string indent)
|
||||||
{
|
{
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
sw.WriteLine(" {");
|
sw.WriteLine(" {");
|
||||||
if (!IsStatic && implementor != null)
|
if (!IsStatic && implementor != null)
|
||||||
implementor.Prepare (sw, indent + "\t\t\t");
|
implementor.Prepare (sw, indent + "\t\t\t");
|
||||||
if (IsAccessor)
|
if (IsAccessor)
|
||||||
Body.InitAccessor (sw, Signature, indent);
|
Body.InitAccessor (sw, Signature, indent);
|
||||||
Body.Initialize(gen_info, is_get, is_set, indent);
|
Body.Initialize(gen_info, is_get, is_set, indent);
|
||||||
|
|
||||||
if (HasWin32Utf8Variant) {
|
if (HasWin32Utf8Variant) {
|
||||||
if (!retval.IsVoid)
|
if (!retval.IsVoid)
|
||||||
sw.WriteLine(indent + "\t\t\t" + retval.MarshalType + " raw_ret;");
|
sw.WriteLine(indent + "\t\t\t" + retval.MarshalType + " raw_ret;");
|
||||||
sw.WriteLine(indent + "\t\t\t" + "if (Environment.OSVersion.Platform == PlatformID.Win32NT ||");
|
sw.WriteLine(indent + "\t\t\t" + "if (Environment.OSVersion.Platform == PlatformID.Win32NT ||");
|
||||||
sw.WriteLine(indent + "\t\t\t" + " Environment.OSVersion.Platform == PlatformID.Win32S ||");
|
sw.WriteLine(indent + "\t\t\t" + " Environment.OSVersion.Platform == PlatformID.Win32S ||");
|
||||||
sw.WriteLine(indent + "\t\t\t" + " Environment.OSVersion.Platform == PlatformID.Win32Windows ||");
|
sw.WriteLine(indent + "\t\t\t" + " Environment.OSVersion.Platform == PlatformID.Win32Windows ||");
|
||||||
sw.WriteLine(indent + "\t\t\t" + " Environment.OSVersion.Platform == PlatformID.WinCE)");
|
sw.WriteLine(indent + "\t\t\t" + " Environment.OSVersion.Platform == PlatformID.WinCE)");
|
||||||
if (retval.IsVoid) {
|
if (retval.IsVoid) {
|
||||||
sw.WriteLine(indent + "\t\t\t\t" + CName + "_utf8" + call + ";");
|
sw.WriteLine(indent + "\t\t\t\t" + CName + "_utf8" + call + ";");
|
||||||
sw.WriteLine(indent + "\t\t\t" + "else");
|
sw.WriteLine(indent + "\t\t\t" + "else");
|
||||||
sw.WriteLine(indent + "\t\t\t\t" + CName + call + ";");
|
sw.WriteLine(indent + "\t\t\t\t" + CName + call + ";");
|
||||||
} else {
|
} else {
|
||||||
sw.WriteLine(indent + "\t\t\t\traw_ret = " + CName + "_utf8" + call + ";");
|
sw.WriteLine(indent + "\t\t\t\traw_ret = " + CName + "_utf8" + call + ";");
|
||||||
sw.WriteLine(indent + "\t\t\t" + "else");
|
sw.WriteLine(indent + "\t\t\t" + "else");
|
||||||
sw.WriteLine(indent + "\t\t\t\traw_ret = " + CName + call + ";");
|
sw.WriteLine(indent + "\t\t\t\traw_ret = " + CName + call + ";");
|
||||||
sw.WriteLine(indent + "\t\t\t" + retval.CSType + " ret = " + retval.FromNative ("raw_ret") + ";");
|
sw.WriteLine(indent + "\t\t\t" + retval.CSType + " ret = " + retval.FromNative ("raw_ret") + ";");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sw.Write(indent + "\t\t\t");
|
sw.Write(indent + "\t\t\t");
|
||||||
if (retval.IsVoid)
|
if (retval.IsVoid)
|
||||||
sw.WriteLine(CName + call + ";");
|
sw.WriteLine(CName + call + ";");
|
||||||
else {
|
else {
|
||||||
sw.WriteLine(retval.MarshalType + " raw_ret = " + CName + call + ";");
|
sw.WriteLine(retval.MarshalType + " raw_ret = " + CName + call + ";");
|
||||||
sw.WriteLine(indent + "\t\t\t" + retval.CSType + " ret = " + retval.FromNative ("raw_ret") + ";");
|
sw.WriteLine(indent + "\t\t\t" + retval.CSType + " ret = " + retval.FromNative ("raw_ret") + ";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsStatic && implementor != null)
|
if (!IsStatic && implementor != null)
|
||||||
implementor.Finish (sw, indent + "\t\t\t");
|
implementor.Finish (sw, indent + "\t\t\t");
|
||||||
Body.Finish (sw, indent);
|
Body.Finish (sw, indent);
|
||||||
Body.HandleException (sw, indent);
|
Body.HandleException (sw, indent);
|
||||||
|
|
||||||
if (is_get && Parameters.Count > 0)
|
if (is_get && Parameters.Count > 0)
|
||||||
sw.WriteLine (indent + "\t\t\treturn " + Parameters.AccessorName + ";");
|
sw.WriteLine (indent + "\t\t\treturn " + Parameters.AccessorName + ";");
|
||||||
else if (!retval.IsVoid)
|
else if (!retval.IsVoid)
|
||||||
sw.WriteLine (indent + "\t\t\treturn ret;");
|
sw.WriteLine (indent + "\t\t\treturn ret;");
|
||||||
else if (IsAccessor)
|
else if (IsAccessor)
|
||||||
Body.FinishAccessor (sw, Signature, indent);
|
Body.FinishAccessor (sw, Signature, indent);
|
||||||
|
|
||||||
sw.Write(indent + "\t\t}");
|
sw.Write(indent + "\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsAccessor {
|
bool IsAccessor {
|
||||||
get {
|
get {
|
||||||
return retval.IsVoid && Signature.IsAccessor;
|
return retval.IsVoid && Signature.IsAccessor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,183 +1,183 @@
|
|||||||
// GtkSharp.Generation.MethodBase.cs - function element base class.
|
// GtkSharp.Generation.MethodBase.cs - function element base class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2004-2005 Novell, Inc.
|
// Copyright (c) 2004-2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public abstract class MethodBase {
|
public abstract class MethodBase {
|
||||||
|
|
||||||
protected XmlElement elem;
|
protected XmlElement elem;
|
||||||
protected ClassBase container_type;
|
protected ClassBase container_type;
|
||||||
protected Parameters parms;
|
protected Parameters parms;
|
||||||
string mods = String.Empty;
|
string mods = String.Empty;
|
||||||
string name;
|
string name;
|
||||||
private string protection = "public";
|
private string protection = "public";
|
||||||
|
|
||||||
protected MethodBase (XmlElement elem, ClassBase container_type)
|
protected MethodBase (XmlElement elem, ClassBase container_type)
|
||||||
{
|
{
|
||||||
this.elem = elem;
|
this.elem = elem;
|
||||||
this.container_type = container_type;
|
this.container_type = container_type;
|
||||||
this.name = elem.GetAttribute ("name");
|
this.name = elem.GetAttribute ("name");
|
||||||
parms = new Parameters (elem ["parameters"]);
|
parms = new Parameters (elem ["parameters"]);
|
||||||
IsStatic = elem.GetAttribute ("shared") == "true";
|
IsStatic = elem.GetAttribute ("shared") == "true";
|
||||||
if (elem.GetAttributeAsBoolean ("new_flag"))
|
if (elem.GetAttributeAsBoolean ("new_flag"))
|
||||||
mods = "new ";
|
mods = "new ";
|
||||||
if (elem.HasAttribute ("accessibility")) {
|
if (elem.HasAttribute ("accessibility")) {
|
||||||
string attr = elem.GetAttribute ("accessibility");
|
string attr = elem.GetAttribute ("accessibility");
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
case "public":
|
case "public":
|
||||||
case "protected":
|
case "protected":
|
||||||
case "internal":
|
case "internal":
|
||||||
case "private":
|
case "private":
|
||||||
case "protected internal":
|
case "protected internal":
|
||||||
protection = attr;
|
protection = attr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string BaseName {
|
protected string BaseName {
|
||||||
get {
|
get {
|
||||||
string name = Name;
|
string name = Name;
|
||||||
int idx = Name.LastIndexOf (".");
|
int idx = Name.LastIndexOf (".");
|
||||||
if (idx > 0)
|
if (idx > 0)
|
||||||
name = Name.Substring (idx + 1);
|
name = Name.Substring (idx + 1);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodBody body;
|
MethodBody body;
|
||||||
public MethodBody Body {
|
public MethodBody Body {
|
||||||
get {
|
get {
|
||||||
if (body == null)
|
if (body == null)
|
||||||
body = new MethodBody (parms);
|
body = new MethodBody (parms);
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string CName {
|
public virtual string CName {
|
||||||
get {
|
get {
|
||||||
return SymbolTable.Table.MangleName (elem.GetAttribute ("cname"));
|
return SymbolTable.Table.MangleName (elem.GetAttribute ("cname"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool HasGetterName {
|
protected bool HasGetterName {
|
||||||
get {
|
get {
|
||||||
string name = BaseName;
|
string name = BaseName;
|
||||||
if (name.Length <= 3)
|
if (name.Length <= 3)
|
||||||
return false;
|
return false;
|
||||||
if (name.StartsWith ("Get") || name.StartsWith ("Has"))
|
if (name.StartsWith ("Get") || name.StartsWith ("Has"))
|
||||||
return Char.IsUpper (name [3]);
|
return Char.IsUpper (name [3]);
|
||||||
else if (name.StartsWith ("Is"))
|
else if (name.StartsWith ("Is"))
|
||||||
return Char.IsUpper (name [2]);
|
return Char.IsUpper (name [2]);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool HasSetterName {
|
protected bool HasSetterName {
|
||||||
get {
|
get {
|
||||||
string name = BaseName;
|
string name = BaseName;
|
||||||
if (name.Length <= 3)
|
if (name.Length <= 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return name.StartsWith ("Set") && Char.IsUpper (name [3]);
|
return name.StartsWith ("Set") && Char.IsUpper (name [3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsStatic {
|
public bool IsStatic {
|
||||||
get {
|
get {
|
||||||
return parms.Static;
|
return parms.Static;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
parms.Static = value;
|
parms.Static = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LibraryName {
|
public string LibraryName {
|
||||||
get {
|
get {
|
||||||
if (elem.HasAttribute ("library"))
|
if (elem.HasAttribute ("library"))
|
||||||
return elem.GetAttribute ("library");
|
return elem.GetAttribute ("library");
|
||||||
return container_type.LibraryName;
|
return container_type.LibraryName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Modifiers {
|
public string Modifiers {
|
||||||
get {
|
get {
|
||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
mods = value;
|
mods = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
name = value;
|
name = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Parameters Parameters {
|
public Parameters Parameters {
|
||||||
get {
|
get {
|
||||||
return parms;
|
return parms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string Protection {
|
public string Protection {
|
||||||
get { return protection; }
|
get { return protection; }
|
||||||
set { protection = value; }
|
set { protection = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string Safety {
|
protected string Safety {
|
||||||
get {
|
get {
|
||||||
return Body.ThrowsException && !(container_type is InterfaceGen) ? "unsafe " : "";
|
return Body.ThrowsException && !(container_type is InterfaceGen) ? "unsafe " : "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Signature sig;
|
Signature sig;
|
||||||
public Signature Signature {
|
public Signature Signature {
|
||||||
get {
|
get {
|
||||||
if (sig == null)
|
if (sig == null)
|
||||||
sig = new Signature (parms);
|
sig = new Signature (parms);
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Validate (LogWriter log)
|
public virtual bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
log.Member = Name;
|
log.Member = Name;
|
||||||
if (!parms.Validate (log)) {
|
if (!parms.Validate (log)) {
|
||||||
Statistics.ThrottledCount++;
|
Statistics.ThrottledCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,180 +1,180 @@
|
|||||||
// GtkSharp.Generation.MethodBody.cs - The MethodBody Generation Class.
|
// GtkSharp.Generation.MethodBody.cs - The MethodBody Generation Class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2003-2004 Novell, Inc.
|
// Copyright (c) 2003-2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
public class MethodBody {
|
public class MethodBody {
|
||||||
|
|
||||||
Parameters parameters;
|
Parameters parameters;
|
||||||
|
|
||||||
public MethodBody (Parameters parms)
|
public MethodBody (Parameters parms)
|
||||||
{
|
{
|
||||||
parameters = parms;
|
parameters = parms;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CastFromInt (string type)
|
private string CastFromInt (string type)
|
||||||
{
|
{
|
||||||
return type != "int" ? "(" + type + ") " : "";
|
return type != "int" ? "(" + type + ") " : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCallString (bool is_set)
|
public string GetCallString (bool is_set)
|
||||||
{
|
{
|
||||||
if (parameters.Count == 0)
|
if (parameters.Count == 0)
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
|
||||||
string[] result = new string [parameters.Count];
|
string[] result = new string [parameters.Count];
|
||||||
for (int i = 0; i < parameters.Count; i++) {
|
for (int i = 0; i < parameters.Count; i++) {
|
||||||
Parameter p = parameters [i];
|
Parameter p = parameters [i];
|
||||||
IGeneratable igen = p.Generatable;
|
IGeneratable igen = p.Generatable;
|
||||||
|
|
||||||
bool is_prop = is_set && i == 0;
|
bool is_prop = is_set && i == 0;
|
||||||
|
|
||||||
if (i > 0 && parameters [i - 1].IsString && p.IsLength && p.PassAs == String.Empty) {
|
if (i > 0 && parameters [i - 1].IsString && p.IsLength && p.PassAs == String.Empty) {
|
||||||
string string_name = (i == 1 && is_set) ? "value" : parameters [i - 1].Name;
|
string string_name = (i == 1 && is_set) ? "value" : parameters [i - 1].Name;
|
||||||
result[i] = igen.CallByName (CastFromInt (p.CSType) + "System.Text.Encoding.UTF8.GetByteCount (" + string_name + ")");
|
result[i] = igen.CallByName (CastFromInt (p.CSType) + "System.Text.Encoding.UTF8.GetByteCount (" + string_name + ")");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_prop)
|
if (is_prop)
|
||||||
p.CallName = "value";
|
p.CallName = "value";
|
||||||
else
|
else
|
||||||
p.CallName = p.Name;
|
p.CallName = p.Name;
|
||||||
string call_parm = p.CallString;
|
string call_parm = p.CallString;
|
||||||
|
|
||||||
if (p.IsUserData && parameters.IsHidden (p) && !parameters.HideData &&
|
if (p.IsUserData && parameters.IsHidden (p) && !parameters.HideData &&
|
||||||
(i == 0 || parameters [i - 1].Scope != "notified")) {
|
(i == 0 || parameters [i - 1].Scope != "notified")) {
|
||||||
call_parm = "IntPtr.Zero";
|
call_parm = "IntPtr.Zero";
|
||||||
}
|
}
|
||||||
|
|
||||||
result [i] += call_parm;
|
result [i] += call_parm;
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.Join (", ", result);
|
return String.Join (", ", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize (GenerationInfo gen_info)
|
public void Initialize (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
Initialize (gen_info, false, false, String.Empty);
|
Initialize (gen_info, false, false, String.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize (GenerationInfo gen_info, bool is_get, bool is_set, string indent)
|
public void Initialize (GenerationInfo gen_info, bool is_get, bool is_set, string indent)
|
||||||
{
|
{
|
||||||
if (parameters.Count == 0)
|
if (parameters.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
for (int i = 0; i < parameters.Count; i++) {
|
for (int i = 0; i < parameters.Count; i++) {
|
||||||
Parameter p = parameters [i];
|
Parameter p = parameters [i];
|
||||||
|
|
||||||
IGeneratable gen = p.Generatable;
|
IGeneratable gen = p.Generatable;
|
||||||
string name = p.Name;
|
string name = p.Name;
|
||||||
if (is_set)
|
if (is_set)
|
||||||
name = "value";
|
name = "value";
|
||||||
|
|
||||||
p.CallName = name;
|
p.CallName = name;
|
||||||
foreach (string prep in p.Prepare)
|
foreach (string prep in p.Prepare)
|
||||||
sw.WriteLine (indent + "\t\t\t" + prep);
|
sw.WriteLine (indent + "\t\t\t" + prep);
|
||||||
|
|
||||||
if (gen is CallbackGen) {
|
if (gen is CallbackGen) {
|
||||||
CallbackGen cbgen = gen as CallbackGen;
|
CallbackGen cbgen = gen as CallbackGen;
|
||||||
string wrapper = cbgen.GenWrapper(gen_info);
|
string wrapper = cbgen.GenWrapper(gen_info);
|
||||||
switch (p.Scope) {
|
switch (p.Scope) {
|
||||||
case "notified":
|
case "notified":
|
||||||
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
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\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\t{0} {1};", parameters [i + 2].CSType, parameters [i + 2].Name);
|
||||||
sw.WriteLine (indent + "\t\t\tif ({0} == null) {{", 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} = 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} = null;", parameters [i + 2].Name);
|
||||||
sw.WriteLine (indent + "\t\t\t} else {");
|
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} = (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} = GLib.DestroyHelper.NotifyHandler;", parameters [i + 2].Name, parameters [i + 2].CSType);
|
||||||
sw.WriteLine (indent + "\t\t\t}");
|
sw.WriteLine (indent + "\t\t\t}");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "async":
|
case "async":
|
||||||
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
||||||
sw.WriteLine (indent + "\t\t\t{0}_wrapper.PersistUntilCalled ();", name);
|
sw.WriteLine (indent + "\t\t\t{0}_wrapper.PersistUntilCalled ();", name);
|
||||||
break;
|
break;
|
||||||
case "call":
|
case "call":
|
||||||
default:
|
default:
|
||||||
if (p.Scope == String.Empty)
|
if (p.Scope == String.Empty)
|
||||||
Console.WriteLine (gen_info.CurrentMember + " - defaulting " + gen.Name + " param to 'call' scope. Specify callback scope (call|async|notified) attribute with fixup.");
|
Console.WriteLine (gen_info.CurrentMember + " - defaulting " + gen.Name + " param to 'call' scope. Specify callback scope (call|async|notified) attribute with fixup.");
|
||||||
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper = new {0} ({1});", wrapper, name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ThrowsException)
|
if (ThrowsException)
|
||||||
sw.WriteLine (indent + "\t\t\tIntPtr error = IntPtr.Zero;");
|
sw.WriteLine (indent + "\t\t\tIntPtr error = IntPtr.Zero;");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitAccessor (StreamWriter sw, Signature sig, string indent)
|
public void InitAccessor (StreamWriter sw, Signature sig, string indent)
|
||||||
{
|
{
|
||||||
sw.WriteLine (indent + "\t\t\t" + sig.AccessorType + " " + sig.AccessorName + ";");
|
sw.WriteLine (indent + "\t\t\t" + sig.AccessorType + " " + sig.AccessorName + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Finish (StreamWriter sw, string indent)
|
public void Finish (StreamWriter sw, string indent)
|
||||||
{
|
{
|
||||||
foreach (Parameter p in parameters) {
|
foreach (Parameter p in parameters) {
|
||||||
if (parameters.IsHidden (p))
|
if (parameters.IsHidden (p))
|
||||||
continue;
|
continue;
|
||||||
foreach (string s in p.Finish)
|
foreach (string s in p.Finish)
|
||||||
sw.WriteLine(indent + "\t\t\t" + s);
|
sw.WriteLine(indent + "\t\t\t" + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinishAccessor (StreamWriter sw, Signature sig, string indent)
|
public void FinishAccessor (StreamWriter sw, Signature sig, string indent)
|
||||||
{
|
{
|
||||||
sw.WriteLine (indent + "\t\t\treturn " + sig.AccessorName + ";");
|
sw.WriteLine (indent + "\t\t\treturn " + sig.AccessorName + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleException (StreamWriter sw, string indent)
|
public void HandleException (StreamWriter sw, string indent)
|
||||||
{
|
{
|
||||||
if (!ThrowsException)
|
if (!ThrowsException)
|
||||||
return;
|
return;
|
||||||
sw.WriteLine (indent + "\t\t\tif (error != IntPtr.Zero) throw new GLib.GException (error);");
|
sw.WriteLine (indent + "\t\t\tif (error != IntPtr.Zero) throw new GLib.GException (error);");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ThrowsException {
|
public bool ThrowsException {
|
||||||
get {
|
get {
|
||||||
int idx = parameters.Count - 1;
|
int idx = parameters.Count - 1;
|
||||||
|
|
||||||
while (idx >= 0) {
|
while (idx >= 0) {
|
||||||
if (parameters [idx].IsUserData)
|
if (parameters [idx].IsUserData)
|
||||||
idx--;
|
idx--;
|
||||||
else if (parameters [idx].CType == "GError**")
|
else if (parameters [idx].CType == "GError**")
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,417 +1,417 @@
|
|||||||
// GtkSharp.Generation.ObjectGen.cs - The Object Generatable.
|
// GtkSharp.Generation.ObjectGen.cs - The Object Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@ximian.com>
|
// Author: Mike Kestner <mkestner@ximian.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2003-2004 Novell, Inc.
|
// Copyright (c) 2003-2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class ObjectGen : ObjectBase {
|
public class ObjectGen : ObjectBase {
|
||||||
|
|
||||||
private ArrayList custom_attrs = new ArrayList();
|
private ArrayList custom_attrs = new ArrayList();
|
||||||
private ArrayList strings = new ArrayList();
|
private ArrayList strings = new ArrayList();
|
||||||
private Hashtable childprops = new Hashtable();
|
private Hashtable childprops = new Hashtable();
|
||||||
private static Hashtable dirs = new Hashtable ();
|
private static Hashtable dirs = new Hashtable ();
|
||||||
|
|
||||||
public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem, false)
|
public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem, false)
|
||||||
{
|
{
|
||||||
foreach (XmlNode node in elem.ChildNodes) {
|
foreach (XmlNode node in elem.ChildNodes) {
|
||||||
if (!(node is XmlElement)) continue;
|
if (!(node is XmlElement)) continue;
|
||||||
XmlElement member = (XmlElement) node;
|
XmlElement member = (XmlElement) node;
|
||||||
if (member.GetAttributeAsBoolean ("hidden"))
|
if (member.GetAttributeAsBoolean ("hidden"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (node.Name) {
|
switch (node.Name) {
|
||||||
case "callback":
|
case "callback":
|
||||||
Statistics.IgnoreCount++;
|
Statistics.IgnoreCount++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "custom-attribute":
|
case "custom-attribute":
|
||||||
custom_attrs.Add (member.InnerXml);
|
custom_attrs.Add (member.InnerXml);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "static-string":
|
case "static-string":
|
||||||
strings.Add (node);
|
strings.Add (node);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "childprop":
|
case "childprop":
|
||||||
string name = member.GetAttribute ("name");
|
string name = member.GetAttribute ("name");
|
||||||
while (childprops.ContainsKey (name))
|
while (childprops.ContainsKey (name))
|
||||||
name += "mangled";
|
name += "mangled";
|
||||||
childprops.Add (name, new ChildProperty (member, this));
|
childprops.Add (name, new ChildProperty (member, this));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!IsNodeNameHandled (node.Name))
|
if (!IsNodeNameHandled (node.Name))
|
||||||
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
|
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var, bool owned)
|
public override string CallByName (string var, bool owned)
|
||||||
{
|
{
|
||||||
return String.Format ("{0} == null ? IntPtr.Zero : {0}.{1}", var, owned ? "OwnedHandle" : "Handle");
|
return String.Format ("{0} == null ? IntPtr.Zero : {0}.{1}", var, owned ? "OwnedHandle" : "Handle");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Validate ()
|
public override bool Validate ()
|
||||||
{
|
{
|
||||||
LogWriter log = new LogWriter (QualifiedName);
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
|
|
||||||
ArrayList invalids = new ArrayList ();
|
ArrayList invalids = new ArrayList ();
|
||||||
|
|
||||||
foreach (ChildProperty prop in childprops.Values) {
|
foreach (ChildProperty prop in childprops.Values) {
|
||||||
if (!prop.Validate (log))
|
if (!prop.Validate (log))
|
||||||
invalids.Add (prop);
|
invalids.Add (prop);
|
||||||
}
|
}
|
||||||
foreach (ChildProperty prop in invalids)
|
foreach (ChildProperty prop in invalids)
|
||||||
childprops.Remove (prop);
|
childprops.Remove (prop);
|
||||||
|
|
||||||
return base.Validate ();
|
return base.Validate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool DisableVoidCtor {
|
private bool DisableVoidCtor {
|
||||||
get {
|
get {
|
||||||
return Elem.GetAttributeAsBoolean ("disable_void_ctor");
|
return Elem.GetAttributeAsBoolean ("disable_void_ctor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DirectoryInfo {
|
private class DirectoryInfo {
|
||||||
public string assembly_name;
|
public string assembly_name;
|
||||||
public Hashtable objects;
|
public Hashtable objects;
|
||||||
|
|
||||||
public DirectoryInfo (string assembly_name) {
|
public DirectoryInfo (string assembly_name) {
|
||||||
this.assembly_name = assembly_name;
|
this.assembly_name = assembly_name;
|
||||||
objects = new Hashtable ();
|
objects = new Hashtable ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DirectoryInfo GetDirectoryInfo (string dir, string assembly_name)
|
private static DirectoryInfo GetDirectoryInfo (string dir, string assembly_name)
|
||||||
{
|
{
|
||||||
DirectoryInfo result;
|
DirectoryInfo result;
|
||||||
|
|
||||||
if (dirs.ContainsKey (dir)) {
|
if (dirs.ContainsKey (dir)) {
|
||||||
result = dirs [dir] as DirectoryInfo;
|
result = dirs [dir] as DirectoryInfo;
|
||||||
if (result.assembly_name != assembly_name) {
|
if (result.assembly_name != assembly_name) {
|
||||||
Console.WriteLine ("Can't put multiple assemblies in one directory.");
|
Console.WriteLine ("Can't put multiple assemblies in one directory.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = new DirectoryInfo (assembly_name);
|
result = new DirectoryInfo (assembly_name);
|
||||||
dirs.Add (dir, result);
|
dirs.Add (dir, result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = QualifiedName;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
string asm_name = gen_info.AssemblyName.Length == 0 ? NS.ToLower () + "-sharp" : gen_info.AssemblyName;
|
string asm_name = gen_info.AssemblyName.Length == 0 ? NS.ToLower () + "-sharp" : gen_info.AssemblyName;
|
||||||
DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, asm_name);
|
DirectoryInfo di = GetDirectoryInfo (gen_info.Dir, asm_name);
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||||
|
|
||||||
sw.WriteLine ("namespace " + NS + " {");
|
sw.WriteLine ("namespace " + NS + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
sw.WriteLine ("\tusing System.Collections;");
|
sw.WriteLine ("\tusing System.Collections;");
|
||||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
SymbolTable table = SymbolTable.Table;
|
SymbolTable table = SymbolTable.Table;
|
||||||
|
|
||||||
sw.WriteLine ("#region Autogenerated code");
|
sw.WriteLine ("#region Autogenerated code");
|
||||||
if (IsDeprecated)
|
if (IsDeprecated)
|
||||||
sw.WriteLine ("\t[Obsolete]");
|
sw.WriteLine ("\t[Obsolete]");
|
||||||
foreach (string attr in custom_attrs)
|
foreach (string attr in custom_attrs)
|
||||||
sw.WriteLine ("\t" + attr);
|
sw.WriteLine ("\t" + attr);
|
||||||
sw.Write ("\t{0} {1}partial class " + Name, IsInternal ? "internal" : "public", IsAbstract ? "abstract " : "");
|
sw.Write ("\t{0} {1}partial class " + Name, IsInternal ? "internal" : "public", IsAbstract ? "abstract " : "");
|
||||||
string cs_parent = table.GetCSType(Elem.GetAttribute("parent"));
|
string cs_parent = table.GetCSType(Elem.GetAttribute("parent"));
|
||||||
if (cs_parent != "") {
|
if (cs_parent != "") {
|
||||||
di.objects.Add (CName, QualifiedName);
|
di.objects.Add (CName, QualifiedName);
|
||||||
sw.Write (" : " + cs_parent);
|
sw.Write (" : " + cs_parent);
|
||||||
}
|
}
|
||||||
foreach (string iface in interfaces) {
|
foreach (string iface in interfaces) {
|
||||||
if (Parent != null && Parent.Implements (iface))
|
if (Parent != null && Parent.Implements (iface))
|
||||||
continue;
|
continue;
|
||||||
sw.Write (", " + table.GetCSType (iface));
|
sw.Write (", " + table.GetCSType (iface));
|
||||||
}
|
}
|
||||||
foreach (string iface in managed_interfaces) {
|
foreach (string iface in managed_interfaces) {
|
||||||
if (Parent != null && Parent.Implements (iface))
|
if (Parent != null && Parent.Implements (iface))
|
||||||
continue;
|
continue;
|
||||||
sw.Write (", " + iface);
|
sw.Write (", " + iface);
|
||||||
}
|
}
|
||||||
sw.WriteLine (" {");
|
sw.WriteLine (" {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
GenCtors (gen_info);
|
GenCtors (gen_info);
|
||||||
GenProperties (gen_info, null);
|
GenProperties (gen_info, null);
|
||||||
GenFields (gen_info);
|
GenFields (gen_info);
|
||||||
GenChildProperties (gen_info);
|
GenChildProperties (gen_info);
|
||||||
|
|
||||||
bool has_sigs = (sigs != null && sigs.Count > 0);
|
bool has_sigs = (sigs != null && sigs.Count > 0);
|
||||||
if (!has_sigs) {
|
if (!has_sigs) {
|
||||||
foreach (string iface in interfaces) {
|
foreach (string iface in interfaces) {
|
||||||
InterfaceGen igen = table.GetClassGen (iface) as InterfaceGen;
|
InterfaceGen igen = table.GetClassGen (iface) as InterfaceGen;
|
||||||
if (igen != null && igen.Signals != null) {
|
if (igen != null && igen.Signals != null) {
|
||||||
has_sigs = true;
|
has_sigs = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_sigs && Elem.HasAttribute("parent")) {
|
if (has_sigs && Elem.HasAttribute("parent")) {
|
||||||
GenSignals (gen_info, null);
|
GenSignals (gen_info, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
GenClassMembers (gen_info, cs_parent);
|
GenClassMembers (gen_info, cs_parent);
|
||||||
GenMethods (gen_info, null, null);
|
GenMethods (gen_info, null, null);
|
||||||
|
|
||||||
if (interfaces.Count != 0) {
|
if (interfaces.Count != 0) {
|
||||||
Hashtable all_methods = new Hashtable ();
|
Hashtable all_methods = new Hashtable ();
|
||||||
foreach (Method m in Methods.Values)
|
foreach (Method m in Methods.Values)
|
||||||
all_methods[m.Name] = m;
|
all_methods[m.Name] = m;
|
||||||
Hashtable collisions = new Hashtable ();
|
Hashtable collisions = new Hashtable ();
|
||||||
foreach (string iface in interfaces) {
|
foreach (string iface in interfaces) {
|
||||||
ClassBase igen = table.GetClassGen (iface);
|
ClassBase igen = table.GetClassGen (iface);
|
||||||
foreach (Method m in igen.Methods.Values) {
|
foreach (Method m in igen.Methods.Values) {
|
||||||
if (m.Name.StartsWith ("Get") || m.Name.StartsWith ("Set")) {
|
if (m.Name.StartsWith ("Get") || m.Name.StartsWith ("Set")) {
|
||||||
if (GetProperty (m.Name.Substring (3)) != null) {
|
if (GetProperty (m.Name.Substring (3)) != null) {
|
||||||
collisions[m.Name] = true;
|
collisions[m.Name] = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Method collision = all_methods[m.Name] as Method;
|
Method collision = all_methods[m.Name] as Method;
|
||||||
if (collision != null && collision.Signature.Types == m.Signature.Types)
|
if (collision != null && collision.Signature.Types == m.Signature.Types)
|
||||||
collisions[m.Name] = true;
|
collisions[m.Name] = true;
|
||||||
else
|
else
|
||||||
all_methods[m.Name] = m;
|
all_methods[m.Name] = m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string iface in interfaces) {
|
foreach (string iface in interfaces) {
|
||||||
if (Parent != null && Parent.Implements (iface))
|
if (Parent != null && Parent.Implements (iface))
|
||||||
continue;
|
continue;
|
||||||
InterfaceGen igen = table.GetClassGen (iface) as InterfaceGen;
|
InterfaceGen igen = table.GetClassGen (iface) as InterfaceGen;
|
||||||
igen.GenMethods (gen_info, collisions, this);
|
igen.GenMethods (gen_info, collisions, this);
|
||||||
igen.GenProperties (gen_info, this);
|
igen.GenProperties (gen_info, this);
|
||||||
igen.GenSignals (gen_info, this);
|
igen.GenSignals (gen_info, this);
|
||||||
igen.GenVirtualMethods (gen_info, this);
|
igen.GenVirtualMethods (gen_info, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (XmlElement str in strings) {
|
foreach (XmlElement str in strings) {
|
||||||
sw.Write ("\t\tpublic static string " + str.GetAttribute ("name"));
|
sw.Write ("\t\tpublic static string " + str.GetAttribute ("name"));
|
||||||
sw.WriteLine (" {\n\t\t\t get { return \"" + str.GetAttribute ("value") + "\"; }\n\t\t}");
|
sw.WriteLine (" {\n\t\t\t get { return \"" + str.GetAttribute ("value") + "\"; }\n\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cs_parent != String.Empty && GetExpected (CName) != QualifiedName) {
|
if (cs_parent != String.Empty && GetExpected (CName) != QualifiedName) {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tstatic " + Name + " ()");
|
sw.WriteLine ("\t\tstatic " + Name + " ()");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tGtkSharp." + Studlify (asm_name) + ".ObjectManager.Initialize ();");
|
sw.WriteLine ("\t\t\tGtkSharp." + Studlify (asm_name) + ".ObjectManager.Initialize ();");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
|
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
gen_info.Writer = null;
|
gen_info.Writer = null;
|
||||||
Statistics.ObjectCount++;
|
Statistics.ObjectCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void GenCtors (GenerationInfo gen_info)
|
protected override void GenCtors (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
if (!Elem.HasAttribute("parent"))
|
if (!Elem.HasAttribute("parent"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||||
if (ctors.Count == 0 && !DisableVoidCtor) {
|
if (ctors.Count == 0 && !DisableVoidCtor) {
|
||||||
gen_info.Writer.WriteLine();
|
gen_info.Writer.WriteLine();
|
||||||
gen_info.Writer.WriteLine("\t\tprotected " + Name + "() : base(IntPtr.Zero)");
|
gen_info.Writer.WriteLine("\t\tprotected " + Name + "() : base(IntPtr.Zero)");
|
||||||
gen_info.Writer.WriteLine("\t\t{");
|
gen_info.Writer.WriteLine("\t\t{");
|
||||||
gen_info.Writer.WriteLine("\t\t\tCreateNativeObject (new string [0], new GLib.Value [0]);");
|
gen_info.Writer.WriteLine("\t\t\tCreateNativeObject (new string [0], new GLib.Value [0]);");
|
||||||
gen_info.Writer.WriteLine("\t\t}");
|
gen_info.Writer.WriteLine("\t\t}");
|
||||||
}
|
}
|
||||||
gen_info.Writer.WriteLine();
|
gen_info.Writer.WriteLine();
|
||||||
|
|
||||||
base.GenCtors (gen_info);
|
base.GenCtors (gen_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void GenChildProperties (GenerationInfo gen_info)
|
protected void GenChildProperties (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
if (childprops.Count == 0)
|
if (childprops.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
|
|
||||||
ObjectGen child_ancestor = Parent as ObjectGen;
|
ObjectGen child_ancestor = Parent as ObjectGen;
|
||||||
while (child_ancestor.CName != "GtkContainer" &&
|
while (child_ancestor.CName != "GtkContainer" &&
|
||||||
child_ancestor.childprops.Count == 0)
|
child_ancestor.childprops.Count == 0)
|
||||||
child_ancestor = child_ancestor.Parent as ObjectGen;
|
child_ancestor = child_ancestor.Parent as ObjectGen;
|
||||||
|
|
||||||
sw.WriteLine ("\t\tpublic class " + Name + "Child : " + child_ancestor.NS + "." + child_ancestor.Name + "." + child_ancestor.Name + "Child {");
|
sw.WriteLine ("\t\tpublic class " + Name + "Child : " + child_ancestor.NS + "." + child_ancestor.Name + "." + child_ancestor.Name + "Child {");
|
||||||
sw.WriteLine ("\t\t\tprotected internal " + Name + "Child (Gtk.Container parent, Gtk.Widget child) : base (parent, child) {}");
|
sw.WriteLine ("\t\t\tprotected internal " + Name + "Child (Gtk.Container parent, Gtk.Widget child) : base (parent, child) {}");
|
||||||
sw.WriteLine ("");
|
sw.WriteLine ("");
|
||||||
|
|
||||||
foreach (ChildProperty prop in childprops.Values)
|
foreach (ChildProperty prop in childprops.Values)
|
||||||
prop.Generate (gen_info, "\t\t\t", null);
|
prop.Generate (gen_info, "\t\t\t", null);
|
||||||
|
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ("");
|
sw.WriteLine ("");
|
||||||
|
|
||||||
sw.WriteLine ("\t\tpublic override Gtk.Container.ContainerChild this [Gtk.Widget child] {");
|
sw.WriteLine ("\t\tpublic override Gtk.Container.ContainerChild this [Gtk.Widget child] {");
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
sw.WriteLine ("\t\t\t\treturn new " + Name + "Child (this, child);");
|
sw.WriteLine ("\t\t\t\treturn new " + Name + "Child (this, child);");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ("");
|
sw.WriteLine ("");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenClassMembers (GenerationInfo gen_info, string cs_parent)
|
void GenClassMembers (GenerationInfo gen_info, string cs_parent)
|
||||||
{
|
{
|
||||||
GenVirtualMethods (gen_info, null);
|
GenVirtualMethods (gen_info, null);
|
||||||
|
|
||||||
if (class_struct_name == null || !CanGenerateClassStruct) return;
|
if (class_struct_name == null || !CanGenerateClassStruct) return;
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
GenerateClassStruct (gen_info);
|
GenerateClassStruct (gen_info);
|
||||||
if (cs_parent == "")
|
if (cs_parent == "")
|
||||||
sw.WriteLine ("\t\tstatic uint class_offset = 0;");
|
sw.WriteLine ("\t\tstatic uint class_offset = 0;");
|
||||||
else
|
else
|
||||||
sw.WriteLine ("\t\tstatic uint class_offset = ((GLib.GType) typeof ({0})).GetClassSize ();", cs_parent);
|
sw.WriteLine ("\t\tstatic uint class_offset = ((GLib.GType) typeof ({0})).GetClassSize ();", cs_parent);
|
||||||
sw.WriteLine ("\t\tstatic Hashtable class_structs;");
|
sw.WriteLine ("\t\tstatic Hashtable class_structs;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tstatic {0} GetClassStruct (GLib.GType gtype, bool use_cache)", class_struct_name);
|
sw.WriteLine ("\t\tstatic {0} GetClassStruct (GLib.GType gtype, bool use_cache)", class_struct_name);
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (class_structs == null)");
|
sw.WriteLine ("\t\t\tif (class_structs == null)");
|
||||||
sw.WriteLine ("\t\t\t\tclass_structs = new Hashtable ();");
|
sw.WriteLine ("\t\t\t\tclass_structs = new Hashtable ();");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t\tif (use_cache && class_structs.Contains (gtype))");
|
sw.WriteLine ("\t\t\tif (use_cache && class_structs.Contains (gtype))");
|
||||||
sw.WriteLine ("\t\t\t\treturn ({0}) class_structs [gtype];", class_struct_name);
|
sw.WriteLine ("\t\t\t\treturn ({0}) class_structs [gtype];", class_struct_name);
|
||||||
sw.WriteLine ("\t\t\telse {");
|
sw.WriteLine ("\t\t\telse {");
|
||||||
sw.WriteLine ("\t\t\t\tIntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);");
|
sw.WriteLine ("\t\t\t\tIntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);");
|
||||||
sw.WriteLine ("\t\t\t\t{0} class_struct = ({0}) Marshal.PtrToStructure (class_ptr, typeof ({0}));", class_struct_name);
|
sw.WriteLine ("\t\t\t\t{0} class_struct = ({0}) Marshal.PtrToStructure (class_ptr, typeof ({0}));", class_struct_name);
|
||||||
sw.WriteLine ("\t\t\t\tif (use_cache)");
|
sw.WriteLine ("\t\t\t\tif (use_cache)");
|
||||||
sw.WriteLine ("\t\t\t\t\tclass_structs.Add (gtype, class_struct);");
|
sw.WriteLine ("\t\t\t\t\tclass_structs.Add (gtype, class_struct);");
|
||||||
sw.WriteLine ("\t\t\t\treturn class_struct;");
|
sw.WriteLine ("\t\t\t\treturn class_struct;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tstatic void OverrideClassStruct (GLib.GType gtype, {0} class_struct)", class_struct_name);
|
sw.WriteLine ("\t\tstatic void OverrideClassStruct (GLib.GType gtype, {0} class_struct)", class_struct_name);
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tIntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);");
|
sw.WriteLine ("\t\t\tIntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);");
|
||||||
sw.WriteLine ("\t\t\tMarshal.StructureToPtr (class_struct, class_ptr, false);");
|
sw.WriteLine ("\t\t\tMarshal.StructureToPtr (class_struct, class_ptr, false);");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep this in sync with the one in glib/GType.cs */
|
/* Keep this in sync with the one in glib/GType.cs */
|
||||||
private static string GetExpected (string cname)
|
private static string GetExpected (string cname)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < cname.Length; i++) {
|
for (int i = 1; i < cname.Length; i++) {
|
||||||
if (Char.IsUpper (cname[i])) {
|
if (Char.IsUpper (cname[i])) {
|
||||||
if (i == 1 && cname[0] == 'G')
|
if (i == 1 && cname[0] == 'G')
|
||||||
return "GLib." + cname.Substring (1);
|
return "GLib." + cname.Substring (1);
|
||||||
else
|
else
|
||||||
return cname.Substring (0, i) + "." + cname.Substring (i);
|
return cname.Substring (0, i) + "." + cname.Substring (i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ArgumentException ("cname doesn't follow the NamespaceType capitalization style: " + cname);
|
throw new ArgumentException ("cname doesn't follow the NamespaceType capitalization style: " + cname);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool NeedsMap (Hashtable objs, string assembly_name)
|
private static bool NeedsMap (Hashtable objs, string assembly_name)
|
||||||
{
|
{
|
||||||
foreach (string key in objs.Keys)
|
foreach (string key in objs.Keys)
|
||||||
if (GetExpected (key) != ((string) objs[key]))
|
if (GetExpected (key) != ((string) objs[key]))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string Studlify (string name)
|
private static string Studlify (string name)
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
|
|
||||||
string[] subs = name.Split ('-');
|
string[] subs = name.Split ('-');
|
||||||
foreach (string sub in subs)
|
foreach (string sub in subs)
|
||||||
result += Char.ToUpper (sub[0]) + sub.Substring (1);
|
result += Char.ToUpper (sub[0]) + sub.Substring (1);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GenerateMappers ()
|
public static void GenerateMappers ()
|
||||||
{
|
{
|
||||||
foreach (string dir in dirs.Keys) {
|
foreach (string dir in dirs.Keys) {
|
||||||
|
|
||||||
DirectoryInfo di = dirs[dir] as DirectoryInfo;
|
DirectoryInfo di = dirs[dir] as DirectoryInfo;
|
||||||
|
|
||||||
if (!NeedsMap (di.objects, di.assembly_name))
|
if (!NeedsMap (di.objects, di.assembly_name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
GenerationInfo gen_info = new GenerationInfo (dir, di.assembly_name);
|
GenerationInfo gen_info = new GenerationInfo (dir, di.assembly_name);
|
||||||
|
|
||||||
GenerateMapper (di, gen_info);
|
GenerateMapper (di, gen_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GenerateMapper (DirectoryInfo dir_info, GenerationInfo gen_info)
|
private static void GenerateMapper (DirectoryInfo dir_info, GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
StreamWriter sw = gen_info.OpenStream ("ObjectManager");
|
StreamWriter sw = gen_info.OpenStream ("ObjectManager");
|
||||||
|
|
||||||
sw.WriteLine ("namespace GtkSharp." + Studlify (dir_info.assembly_name) + " {");
|
sw.WriteLine ("namespace GtkSharp." + Studlify (dir_info.assembly_name) + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tpublic class ObjectManager {");
|
sw.WriteLine ("\tpublic class ObjectManager {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tstatic bool initialized = false;");
|
sw.WriteLine ("\t\tstatic bool initialized = false;");
|
||||||
sw.WriteLine ("\t\t// Call this method from the appropriate module init function.");
|
sw.WriteLine ("\t\t// Call this method from the appropriate module init function.");
|
||||||
sw.WriteLine ("\t\tpublic static void Initialize ()");
|
sw.WriteLine ("\t\tpublic static void Initialize ()");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (initialized)");
|
sw.WriteLine ("\t\t\tif (initialized)");
|
||||||
sw.WriteLine ("\t\t\t\treturn;");
|
sw.WriteLine ("\t\t\t\treturn;");
|
||||||
sw.WriteLine ("");
|
sw.WriteLine ("");
|
||||||
sw.WriteLine ("\t\t\tinitialized = true;");
|
sw.WriteLine ("\t\t\tinitialized = true;");
|
||||||
|
|
||||||
foreach (string key in dir_info.objects.Keys) {
|
foreach (string key in dir_info.objects.Keys) {
|
||||||
if (GetExpected(key) != ((string) dir_info.objects[key]))
|
if (GetExpected(key) != ((string) dir_info.objects[key]))
|
||||||
sw.WriteLine ("\t\t\tGLib.GType.Register ({0}.GType, typeof ({0}));", dir_info.objects [key]);
|
sw.WriteLine ("\t\t\tGLib.GType.Register ({0}.GType, typeof ({0}));", dir_info.objects [key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,235 +1,235 @@
|
|||||||
// GtkSharp.Generation.OpaqueGen.cs - The Opaque Generatable.
|
// GtkSharp.Generation.OpaqueGen.cs - The Opaque Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class OpaqueGen : HandleBase {
|
public class OpaqueGen : HandleBase {
|
||||||
|
|
||||||
public OpaqueGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
public OpaqueGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
||||||
|
|
||||||
public override string FromNative(string var, bool owned)
|
public override string FromNative(string var, bool owned)
|
||||||
{
|
{
|
||||||
return var + " == IntPtr.Zero ? null : (" + QualifiedName + ") GLib.Opaque.GetOpaque (" + var + ", typeof (" + QualifiedName + "), " + (owned ? "true" : "false") + ")";
|
return var + " == IntPtr.Zero ? null : (" + QualifiedName + ") GLib.Opaque.GetOpaque (" + var + ", typeof (" + QualifiedName + "), " + (owned ? "true" : "false") + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool DisableRawCtor {
|
private bool DisableRawCtor {
|
||||||
get {
|
get {
|
||||||
return Elem.GetAttributeAsBoolean ("disable_raw_ctor");
|
return Elem.GetAttributeAsBoolean ("disable_raw_ctor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = QualifiedName;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||||
|
|
||||||
sw.WriteLine ("namespace " + NS + " {");
|
sw.WriteLine ("namespace " + NS + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
sw.WriteLine ("\tusing System.Collections;");
|
sw.WriteLine ("\tusing System.Collections;");
|
||||||
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
sw.WriteLine ("#region Autogenerated code");
|
sw.WriteLine ("#region Autogenerated code");
|
||||||
|
|
||||||
SymbolTable table = SymbolTable.Table;
|
SymbolTable table = SymbolTable.Table;
|
||||||
|
|
||||||
Method ref_, unref, dispose;
|
Method ref_, unref, dispose;
|
||||||
GetSpecialMethods (out ref_, out unref, out dispose);
|
GetSpecialMethods (out ref_, out unref, out dispose);
|
||||||
|
|
||||||
if (IsDeprecated)
|
if (IsDeprecated)
|
||||||
sw.WriteLine ("\t[Obsolete]");
|
sw.WriteLine ("\t[Obsolete]");
|
||||||
sw.Write ("\t{0} partial {1}class " + Name, IsInternal ? "internal" : "public", IsAbstract ? "abstract " : String.Empty);
|
sw.Write ("\t{0} partial {1}class " + Name, IsInternal ? "internal" : "public", IsAbstract ? "abstract " : String.Empty);
|
||||||
string cs_parent = table.GetCSType(Elem.GetAttribute("parent"));
|
string cs_parent = table.GetCSType(Elem.GetAttribute("parent"));
|
||||||
if (cs_parent != "")
|
if (cs_parent != "")
|
||||||
sw.Write (" : " + cs_parent);
|
sw.Write (" : " + cs_parent);
|
||||||
else
|
else
|
||||||
sw.Write (" : GLib.Opaque");
|
sw.Write (" : GLib.Opaque");
|
||||||
|
|
||||||
foreach (string iface in managed_interfaces) {
|
foreach (string iface in managed_interfaces) {
|
||||||
if (Parent != null && Parent.Implements (iface))
|
if (Parent != null && Parent.Implements (iface))
|
||||||
continue;
|
continue;
|
||||||
sw.Write (", " + iface);
|
sw.Write (", " + iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine (" {");
|
sw.WriteLine (" {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
GenFields (gen_info);
|
GenFields (gen_info);
|
||||||
GenMethods (gen_info, null, null);
|
GenMethods (gen_info, null, null);
|
||||||
GenCtors (gen_info);
|
GenCtors (gen_info);
|
||||||
|
|
||||||
if (ref_ != null) {
|
if (ref_ != null) {
|
||||||
ref_.GenerateImport (sw);
|
ref_.GenerateImport (sw);
|
||||||
sw.WriteLine ("\t\tprotected override void Ref (IntPtr raw)");
|
sw.WriteLine ("\t\tprotected override void Ref (IntPtr raw)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (!Owned) {");
|
sw.WriteLine ("\t\t\tif (!Owned) {");
|
||||||
sw.WriteLine ("\t\t\t\t" + ref_.CName + " (raw);");
|
sw.WriteLine ("\t\t\t\t" + ref_.CName + " (raw);");
|
||||||
sw.WriteLine ("\t\t\t\tOwned = true;");
|
sw.WriteLine ("\t\t\t\tOwned = true;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
if (ref_.IsDeprecated) {
|
if (ref_.IsDeprecated) {
|
||||||
sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now refcounted automatically\")]");
|
sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now refcounted automatically\")]");
|
||||||
if (ref_.ReturnType == "void")
|
if (ref_.ReturnType == "void")
|
||||||
sw.WriteLine ("\t\tpublic void Ref () {}");
|
sw.WriteLine ("\t\tpublic void Ref () {}");
|
||||||
else
|
else
|
||||||
sw.WriteLine ("\t\tpublic " + Name + " Ref () { return this; }");
|
sw.WriteLine ("\t\tpublic " + Name + " Ref () { return this; }");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool finalizer_needed = false;
|
bool finalizer_needed = false;
|
||||||
|
|
||||||
if (unref != null) {
|
if (unref != null) {
|
||||||
unref.GenerateImport (sw);
|
unref.GenerateImport (sw);
|
||||||
sw.WriteLine ("\t\tprotected override void Unref (IntPtr raw)");
|
sw.WriteLine ("\t\tprotected override void Unref (IntPtr raw)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (Owned) {");
|
sw.WriteLine ("\t\t\tif (Owned) {");
|
||||||
sw.WriteLine ("\t\t\t\t" + unref.CName + " (raw);");
|
sw.WriteLine ("\t\t\t\t" + unref.CName + " (raw);");
|
||||||
sw.WriteLine ("\t\t\t\tOwned = false;");
|
sw.WriteLine ("\t\t\t\tOwned = false;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
if (unref.IsDeprecated) {
|
if (unref.IsDeprecated) {
|
||||||
sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now refcounted automatically\")]");
|
sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now refcounted automatically\")]");
|
||||||
sw.WriteLine ("\t\tpublic void Unref () {}");
|
sw.WriteLine ("\t\tpublic void Unref () {}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
finalizer_needed = true;
|
finalizer_needed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dispose != null) {
|
if (dispose != null) {
|
||||||
dispose.GenerateImport (sw);
|
dispose.GenerateImport (sw);
|
||||||
sw.WriteLine ("\t\tprotected override void Free (IntPtr raw)");
|
sw.WriteLine ("\t\tprotected override void Free (IntPtr raw)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\t" + dispose.CName + " (raw);");
|
sw.WriteLine ("\t\t\t" + dispose.CName + " (raw);");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
if (dispose.IsDeprecated) {
|
if (dispose.IsDeprecated) {
|
||||||
sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now freed automatically\")]");
|
sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now freed automatically\")]");
|
||||||
sw.WriteLine ("\t\tpublic void " + dispose.Name + " () {}");
|
sw.WriteLine ("\t\tpublic void " + dispose.Name + " () {}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
finalizer_needed = true;
|
finalizer_needed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalizer_needed) {
|
if (finalizer_needed) {
|
||||||
sw.WriteLine ("\t\tclass FinalizerInfo {");
|
sw.WriteLine ("\t\tclass FinalizerInfo {");
|
||||||
sw.WriteLine ("\t\t\tIntPtr handle;");
|
sw.WriteLine ("\t\t\tIntPtr handle;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t\tpublic FinalizerInfo (IntPtr handle)");
|
sw.WriteLine ("\t\t\tpublic FinalizerInfo (IntPtr handle)");
|
||||||
sw.WriteLine ("\t\t\t{");
|
sw.WriteLine ("\t\t\t{");
|
||||||
sw.WriteLine ("\t\t\t\tthis.handle = handle;");
|
sw.WriteLine ("\t\t\t\tthis.handle = handle;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t\tpublic bool Handler ()");
|
sw.WriteLine ("\t\t\tpublic bool Handler ()");
|
||||||
sw.WriteLine ("\t\t\t{");
|
sw.WriteLine ("\t\t\t{");
|
||||||
if (dispose != null)
|
if (dispose != null)
|
||||||
sw.WriteLine ("\t\t\t\t{0} (handle);", dispose.CName);
|
sw.WriteLine ("\t\t\t\t{0} (handle);", dispose.CName);
|
||||||
else if (unref != null)
|
else if (unref != null)
|
||||||
sw.WriteLine ("\t\t\t\t{0} (handle);", unref.CName);
|
sw.WriteLine ("\t\t\t\t{0} (handle);", unref.CName);
|
||||||
sw.WriteLine ("\t\t\t\treturn false;");
|
sw.WriteLine ("\t\t\t\treturn false;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\t~{0} ()", Name);
|
sw.WriteLine ("\t\t~{0} ()", Name);
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tif (!Owned)");
|
sw.WriteLine ("\t\t\tif (!Owned)");
|
||||||
sw.WriteLine ("\t\t\t\treturn;");
|
sw.WriteLine ("\t\t\t\treturn;");
|
||||||
sw.WriteLine ("\t\t\tFinalizerInfo info = new FinalizerInfo (Handle);");
|
sw.WriteLine ("\t\t\tFinalizerInfo info = new FinalizerInfo (Handle);");
|
||||||
sw.WriteLine ("\t\t\tGLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));");
|
sw.WriteLine ("\t\t\tGLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if false
|
#if false
|
||||||
Method copy = Methods ["Copy"] as Method;
|
Method copy = Methods ["Copy"] as Method;
|
||||||
if (copy != null && copy.Parameters.Count == 0) {
|
if (copy != null && copy.Parameters.Count == 0) {
|
||||||
sw.WriteLine ("\t\tprotected override GLib.Opaque Copy (IntPtr raw)");
|
sw.WriteLine ("\t\tprotected override GLib.Opaque Copy (IntPtr raw)");
|
||||||
sw.WriteLine ("\t\t{");
|
sw.WriteLine ("\t\t{");
|
||||||
sw.WriteLine ("\t\t\tGLib.Opaque result = new " + QualifiedName + " (" + copy.CName + " (raw));");
|
sw.WriteLine ("\t\t\tGLib.Opaque result = new " + QualifiedName + " (" + copy.CName + " (raw));");
|
||||||
sw.WriteLine ("\t\t\tresult.Owned = true;");
|
sw.WriteLine ("\t\t\tresult.Owned = true;");
|
||||||
sw.WriteLine ("\t\t\treturn result;");
|
sw.WriteLine ("\t\t\treturn result;");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
|
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
gen_info.Writer = null;
|
gen_info.Writer = null;
|
||||||
Statistics.OpaqueCount++;
|
Statistics.OpaqueCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetSpecialMethods (out Method ref_, out Method unref, out Method dispose)
|
void GetSpecialMethods (out Method ref_, out Method unref, out Method dispose)
|
||||||
{
|
{
|
||||||
ref_ = CheckSpecialMethod (GetMethod ("Ref"));
|
ref_ = CheckSpecialMethod (GetMethod ("Ref"));
|
||||||
unref = CheckSpecialMethod (GetMethod ("Unref"));
|
unref = CheckSpecialMethod (GetMethod ("Unref"));
|
||||||
|
|
||||||
dispose = GetMethod ("Free");
|
dispose = GetMethod ("Free");
|
||||||
if (dispose == null) {
|
if (dispose == null) {
|
||||||
dispose = GetMethod ("Destroy");
|
dispose = GetMethod ("Destroy");
|
||||||
if (dispose == null)
|
if (dispose == null)
|
||||||
dispose = GetMethod ("Dispose");
|
dispose = GetMethod ("Dispose");
|
||||||
}
|
}
|
||||||
dispose = CheckSpecialMethod (dispose);
|
dispose = CheckSpecialMethod (dispose);
|
||||||
}
|
}
|
||||||
|
|
||||||
Method CheckSpecialMethod (Method method)
|
Method CheckSpecialMethod (Method method)
|
||||||
{
|
{
|
||||||
if (method == null)
|
if (method == null)
|
||||||
return null;
|
return null;
|
||||||
if (method.ReturnType != "void" &&
|
if (method.ReturnType != "void" &&
|
||||||
method.ReturnType != QualifiedName)
|
method.ReturnType != QualifiedName)
|
||||||
return null;
|
return null;
|
||||||
if (method.Signature.ToString () != "")
|
if (method.Signature.ToString () != "")
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
methods.Remove (method.Name);
|
methods.Remove (method.Name);
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void GenCtors (GenerationInfo gen_info)
|
protected override void GenCtors (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
if (!DisableRawCtor) {
|
if (!DisableRawCtor) {
|
||||||
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
gen_info.Writer.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||||
gen_info.Writer.WriteLine();
|
gen_info.Writer.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
base.GenCtors (gen_info);
|
base.GenCtors (gen_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,51 +1,51 @@
|
|||||||
// GtkSharp.Generation.ManualGen.cs - Ungenerated handle type Generatable.
|
// GtkSharp.Generation.ManualGen.cs - Ungenerated handle type Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003 Mike Kestner
|
// Copyright (c) 2003 Mike Kestner
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class OwnableGen : SimpleBase, IOwnable {
|
public class OwnableGen : SimpleBase, IOwnable {
|
||||||
|
|
||||||
public OwnableGen (string ctype, string type) : base (ctype, type, "null") {}
|
public OwnableGen (string ctype, string type) : base (ctype, type, "null") {}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get { return "IntPtr"; }
|
get { return "IntPtr"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var_name)
|
public override string CallByName (string var_name)
|
||||||
{
|
{
|
||||||
return var_name + " == null ? IntPtr.Zero : " + var_name + ".Handle";
|
return var_name + " == null ? IntPtr.Zero : " + var_name + ".Handle";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string FromNative (string var)
|
public override string FromNative (string var)
|
||||||
{
|
{
|
||||||
return String.Format ("new {0} ({1})", QualifiedName, var);
|
return String.Format ("new {0} ({1})", QualifiedName, var);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FromNative (string var, bool owned)
|
public string FromNative (string var, bool owned)
|
||||||
{
|
{
|
||||||
return String.Format ("new {0} ({1}, {2})", QualifiedName, var, owned ? "true" : "false");
|
return String.Format ("new {0} ({1}, {2})", QualifiedName, var, owned ? "true" : "false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,186 +1,186 @@
|
|||||||
// GtkSharp.Generation.Parser.cs - The XML Parsing engine.
|
// GtkSharp.Generation.Parser.cs - The XML Parsing engine.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2003 Ximian Inc.
|
// Copyright (c) 2003 Ximian Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class Parser {
|
public class Parser {
|
||||||
const int curr_parser_version = 2;
|
const int curr_parser_version = 2;
|
||||||
|
|
||||||
private XmlDocument Load (string filename)
|
private XmlDocument Load (string filename)
|
||||||
{
|
{
|
||||||
XmlDocument doc = new XmlDocument ();
|
XmlDocument doc = new XmlDocument ();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Stream stream = File.OpenRead (filename);
|
Stream stream = File.OpenRead (filename);
|
||||||
doc.Load (stream);
|
doc.Load (stream);
|
||||||
stream.Close ();
|
stream.Close ();
|
||||||
} catch (XmlException e) {
|
} catch (XmlException e) {
|
||||||
Console.WriteLine ("Invalid XML file.");
|
Console.WriteLine ("Invalid XML file.");
|
||||||
Console.WriteLine (e);
|
Console.WriteLine (e);
|
||||||
doc = null;
|
doc = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IGeneratable[] Parse (string filename)
|
public IGeneratable[] Parse (string filename)
|
||||||
{
|
{
|
||||||
XmlDocument doc = Load (filename);
|
XmlDocument doc = Load (filename);
|
||||||
if (doc == null)
|
if (doc == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
XmlElement root = doc.DocumentElement;
|
XmlElement root = doc.DocumentElement;
|
||||||
|
|
||||||
if ((root == null) || !root.HasChildNodes) {
|
if ((root == null) || !root.HasChildNodes) {
|
||||||
Console.WriteLine ("No Namespaces found.");
|
Console.WriteLine ("No Namespaces found.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parser_version;
|
int parser_version;
|
||||||
if (root.HasAttribute ("parser_version")) {
|
if (root.HasAttribute ("parser_version")) {
|
||||||
try {
|
try {
|
||||||
parser_version = int.Parse (root.GetAttribute ("parser_version"));
|
parser_version = int.Parse (root.GetAttribute ("parser_version"));
|
||||||
} catch {
|
} catch {
|
||||||
Console.WriteLine ("ERROR: Unable to parse parser_version attribute value \"{0}\" to a number. Input file {1} will be ignored", root.GetAttribute ("parser_version"), filename);
|
Console.WriteLine ("ERROR: Unable to parse parser_version attribute value \"{0}\" to a number. Input file {1} will be ignored", root.GetAttribute ("parser_version"), filename);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
parser_version = 1;
|
parser_version = 1;
|
||||||
|
|
||||||
if (parser_version > curr_parser_version)
|
if (parser_version > curr_parser_version)
|
||||||
Console.WriteLine ("WARNING: The input file {0} was created by a parser that was released after this version of the generator. Consider updating the code generator if you experience problems.", filename);
|
Console.WriteLine ("WARNING: The input file {0} was created by a parser that was released after this version of the generator. Consider updating the code generator if you experience problems.", filename);
|
||||||
|
|
||||||
ArrayList gens = new ArrayList ();
|
ArrayList gens = new ArrayList ();
|
||||||
|
|
||||||
foreach (XmlNode child in root.ChildNodes) {
|
foreach (XmlNode child in root.ChildNodes) {
|
||||||
XmlElement elem = child as XmlElement;
|
XmlElement elem = child as XmlElement;
|
||||||
if (elem == null)
|
if (elem == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (child.Name) {
|
switch (child.Name) {
|
||||||
case "namespace":
|
case "namespace":
|
||||||
gens.AddRange (ParseNamespace (elem));
|
gens.AddRange (ParseNamespace (elem));
|
||||||
break;
|
break;
|
||||||
case "symbol":
|
case "symbol":
|
||||||
gens.Add (ParseSymbol (elem));
|
gens.Add (ParseSymbol (elem));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine ("Parser::Parse - Unexpected child node: " + child.Name);
|
Console.WriteLine ("Parser::Parse - Unexpected child node: " + child.Name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IGeneratable[]) gens.ToArray (typeof (IGeneratable));
|
return (IGeneratable[]) gens.ToArray (typeof (IGeneratable));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList ParseNamespace (XmlElement ns)
|
private ArrayList ParseNamespace (XmlElement ns)
|
||||||
{
|
{
|
||||||
ArrayList result = new ArrayList ();
|
ArrayList result = new ArrayList ();
|
||||||
|
|
||||||
foreach (XmlNode def in ns.ChildNodes) {
|
foreach (XmlNode def in ns.ChildNodes) {
|
||||||
|
|
||||||
XmlElement elem = def as XmlElement;
|
XmlElement elem = def as XmlElement;
|
||||||
if (elem == null)
|
if (elem == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (elem.GetAttributeAsBoolean ("hidden"))
|
if (elem.GetAttributeAsBoolean ("hidden"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool is_opaque = elem.GetAttributeAsBoolean ("opaque");
|
bool is_opaque = elem.GetAttributeAsBoolean ("opaque");
|
||||||
|
|
||||||
switch (def.Name) {
|
switch (def.Name) {
|
||||||
case "alias":
|
case "alias":
|
||||||
string aname = elem.GetAttribute("cname");
|
string aname = elem.GetAttribute("cname");
|
||||||
string atype = elem.GetAttribute("type");
|
string atype = elem.GetAttribute("type");
|
||||||
if ((aname == "") || (atype == ""))
|
if ((aname == "") || (atype == ""))
|
||||||
continue;
|
continue;
|
||||||
result.Add (new AliasGen (aname, atype));
|
result.Add (new AliasGen (aname, atype));
|
||||||
break;
|
break;
|
||||||
case "boxed":
|
case "boxed":
|
||||||
result.Add (is_opaque ? new OpaqueGen (ns, elem) as object : new BoxedGen (ns, elem) as object);
|
result.Add (is_opaque ? new OpaqueGen (ns, elem) as object : new BoxedGen (ns, elem) as object);
|
||||||
break;
|
break;
|
||||||
case "callback":
|
case "callback":
|
||||||
result.Add (new CallbackGen (ns, elem));
|
result.Add (new CallbackGen (ns, elem));
|
||||||
break;
|
break;
|
||||||
case "enum":
|
case "enum":
|
||||||
result.Add (new EnumGen (ns, elem));
|
result.Add (new EnumGen (ns, elem));
|
||||||
break;
|
break;
|
||||||
case "interface":
|
case "interface":
|
||||||
result.Add (new InterfaceGen (ns, elem));
|
result.Add (new InterfaceGen (ns, elem));
|
||||||
break;
|
break;
|
||||||
case "object":
|
case "object":
|
||||||
result.Add (new ObjectGen (ns, elem));
|
result.Add (new ObjectGen (ns, elem));
|
||||||
break;
|
break;
|
||||||
case "class":
|
case "class":
|
||||||
result.Add (new ClassGen (ns, elem));
|
result.Add (new ClassGen (ns, elem));
|
||||||
break;
|
break;
|
||||||
case "struct":
|
case "struct":
|
||||||
result.Add (is_opaque ? new OpaqueGen (ns, elem) as object : new StructGen (ns, elem) as object);
|
result.Add (is_opaque ? new OpaqueGen (ns, elem) as object : new StructGen (ns, elem) as object);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine ("Parser::ParseNamespace - Unexpected node: " + def.Name);
|
Console.WriteLine ("Parser::ParseNamespace - Unexpected node: " + def.Name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IGeneratable ParseSymbol (XmlElement symbol)
|
private IGeneratable ParseSymbol (XmlElement symbol)
|
||||||
{
|
{
|
||||||
string type = symbol.GetAttribute ("type");
|
string type = symbol.GetAttribute ("type");
|
||||||
string cname = symbol.GetAttribute ("cname");
|
string cname = symbol.GetAttribute ("cname");
|
||||||
string name = symbol.GetAttribute ("name");
|
string name = symbol.GetAttribute ("name");
|
||||||
IGeneratable result = null;
|
IGeneratable result = null;
|
||||||
|
|
||||||
if (type == "simple") {
|
if (type == "simple") {
|
||||||
if (symbol.HasAttribute ("default_value"))
|
if (symbol.HasAttribute ("default_value"))
|
||||||
result = new SimpleGen (cname, name, symbol.GetAttribute ("default_value"));
|
result = new SimpleGen (cname, name, symbol.GetAttribute ("default_value"));
|
||||||
else {
|
else {
|
||||||
Console.WriteLine ("Simple type element " + cname + " has no specified default value");
|
Console.WriteLine ("Simple type element " + cname + " has no specified default value");
|
||||||
result = new SimpleGen (cname, name, String.Empty);
|
result = new SimpleGen (cname, name, String.Empty);
|
||||||
}
|
}
|
||||||
} else if (type == "manual")
|
} else if (type == "manual")
|
||||||
result = new ManualGen (cname, name);
|
result = new ManualGen (cname, name);
|
||||||
else if (type == "ownable")
|
else if (type == "ownable")
|
||||||
result = new OwnableGen (cname, name);
|
result = new OwnableGen (cname, name);
|
||||||
else if (type == "alias")
|
else if (type == "alias")
|
||||||
result = new AliasGen (cname, name);
|
result = new AliasGen (cname, name);
|
||||||
else if (type == "marshal") {
|
else if (type == "marshal") {
|
||||||
string mtype = symbol.GetAttribute ("marshal_type");
|
string mtype = symbol.GetAttribute ("marshal_type");
|
||||||
string call = symbol.GetAttribute ("call_fmt");
|
string call = symbol.GetAttribute ("call_fmt");
|
||||||
string from = symbol.GetAttribute ("from_fmt");
|
string from = symbol.GetAttribute ("from_fmt");
|
||||||
result = new MarshalGen (cname, name, mtype, call, from);
|
result = new MarshalGen (cname, name, mtype, call, from);
|
||||||
} else if (type == "struct") {
|
} else if (type == "struct") {
|
||||||
result = new ByRefGen (symbol.GetAttribute ("cname"), symbol.GetAttribute ("name"));
|
result = new ByRefGen (symbol.GetAttribute ("cname"), symbol.GetAttribute ("name"));
|
||||||
} else
|
} else
|
||||||
Console.WriteLine ("Parser::ParseSymbol - Unexpected symbol type " + type);
|
Console.WriteLine ("Parser::ParseSymbol - Unexpected symbol type " + type);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,193 +1,193 @@
|
|||||||
// GtkSharp.Generation.Property.cs - The Property Generatable.
|
// GtkSharp.Generation.Property.cs - The Property Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class Property : PropertyBase {
|
public class Property : PropertyBase {
|
||||||
|
|
||||||
public Property (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
public Property (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
|
||||||
|
|
||||||
public bool Validate (LogWriter log)
|
public bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (CSType == "" && !Hidden) {
|
if (CSType == "" && !Hidden) {
|
||||||
log.Member = Name;
|
log.Member = Name;
|
||||||
log.Warn ("property has unknown type '{0}' ", CType);
|
log.Warn ("property has unknown type '{0}' ", CType);
|
||||||
Statistics.ThrottledCount++;
|
Statistics.ThrottledCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Readable {
|
bool Readable {
|
||||||
get {
|
get {
|
||||||
return elem.GetAttributeAsBoolean ("readable");
|
return elem.GetAttributeAsBoolean ("readable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Writable {
|
bool Writable {
|
||||||
get {
|
get {
|
||||||
return elem.GetAttributeAsBoolean ("writeable") &&
|
return elem.GetAttributeAsBoolean ("writeable") &&
|
||||||
!elem.GetAttributeAsBoolean ("construct-only");
|
!elem.GetAttributeAsBoolean ("construct-only");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsDeprecated {
|
bool IsDeprecated {
|
||||||
get {
|
get {
|
||||||
return !container_type.IsDeprecated &&
|
return !container_type.IsDeprecated &&
|
||||||
elem.GetAttributeAsBoolean ("deprecated");
|
elem.GetAttributeAsBoolean ("deprecated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string PropertyAttribute (string qpname) {
|
protected virtual string PropertyAttribute (string qpname) {
|
||||||
return "[GLib.Property (" + qpname + ")]";
|
return "[GLib.Property (" + qpname + ")]";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string RawGetter (string qpname) {
|
protected virtual string RawGetter (string qpname) {
|
||||||
return "GetProperty (" + qpname + ")";
|
return "GetProperty (" + qpname + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string RawSetter (string qpname) {
|
protected virtual string RawSetter (string qpname) {
|
||||||
return "SetProperty(" + qpname + ", val)";
|
return "SetProperty(" + qpname + ", val)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateDecl (StreamWriter sw, string indent)
|
public void GenerateDecl (StreamWriter sw, string indent)
|
||||||
{
|
{
|
||||||
if (Hidden || (!Readable && !Writable))
|
if (Hidden || (!Readable && !Writable))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string name = Name;
|
string name = Name;
|
||||||
if (name == container_type.Name)
|
if (name == container_type.Name)
|
||||||
name += "Prop";
|
name += "Prop";
|
||||||
|
|
||||||
sw.WriteLine (indent + CSType + " " + name + " {");
|
sw.WriteLine (indent + CSType + " " + name + " {");
|
||||||
sw.Write (indent + "\t");
|
sw.Write (indent + "\t");
|
||||||
if (Readable || Getter != null)
|
if (Readable || Getter != null)
|
||||||
sw.Write ("get; ");
|
sw.Write ("get; ");
|
||||||
if (Writable || Setter != null)
|
if (Writable || Setter != null)
|
||||||
sw.Write ("set;");
|
sw.Write ("set;");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine (indent + "}");
|
sw.WriteLine (indent + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate (GenerationInfo gen_info, string indent, ClassBase implementor)
|
public void Generate (GenerationInfo gen_info, string indent, ClassBase implementor)
|
||||||
{
|
{
|
||||||
SymbolTable table = SymbolTable.Table;
|
SymbolTable table = SymbolTable.Table;
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
|
|
||||||
if (Hidden || (!Readable && !Writable))
|
if (Hidden || (!Readable && !Writable))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string modifiers = "";
|
string modifiers = "";
|
||||||
|
|
||||||
if (IsNew || (container_type.Parent != null && container_type.Parent.GetPropertyRecursively (Name) != null))
|
if (IsNew || (container_type.Parent != null && container_type.Parent.GetPropertyRecursively (Name) != null))
|
||||||
modifiers = "new ";
|
modifiers = "new ";
|
||||||
else if (implementor != null && implementor.Parent != null && implementor.Parent.GetPropertyRecursively (Name) != null)
|
else if (implementor != null && implementor.Parent != null && implementor.Parent.GetPropertyRecursively (Name) != null)
|
||||||
modifiers = "new ";
|
modifiers = "new ";
|
||||||
|
|
||||||
string name = Name;
|
string name = Name;
|
||||||
if (name == container_type.Name) {
|
if (name == container_type.Name) {
|
||||||
name += "Prop";
|
name += "Prop";
|
||||||
}
|
}
|
||||||
string qpname = "\"" + CName + "\"";
|
string qpname = "\"" + CName + "\"";
|
||||||
|
|
||||||
string v_type = "";
|
string v_type = "";
|
||||||
if (table.IsInterface (CType)) {
|
if (table.IsInterface (CType)) {
|
||||||
v_type = "(GLib.Object)";
|
v_type = "(GLib.Object)";
|
||||||
} else if (table.IsOpaque (CType)) {
|
} else if (table.IsOpaque (CType)) {
|
||||||
v_type = "(GLib.Opaque)";
|
v_type = "(GLib.Opaque)";
|
||||||
} else if (table.IsEnum (CType)) {
|
} else if (table.IsEnum (CType)) {
|
||||||
v_type = "(Enum)";
|
v_type = "(Enum)";
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateImports (gen_info, indent);
|
GenerateImports (gen_info, indent);
|
||||||
|
|
||||||
if (IsDeprecated ||
|
if (IsDeprecated ||
|
||||||
(Getter != null && Getter.IsDeprecated) ||
|
(Getter != null && Getter.IsDeprecated) ||
|
||||||
(Setter != null && Setter.IsDeprecated))
|
(Setter != null && Setter.IsDeprecated))
|
||||||
sw.WriteLine (indent + "[Obsolete]");
|
sw.WriteLine (indent + "[Obsolete]");
|
||||||
sw.WriteLine (indent + PropertyAttribute (qpname));
|
sw.WriteLine (indent + PropertyAttribute (qpname));
|
||||||
sw.WriteLine (indent + "public " + modifiers + CSType + " " + name + " {");
|
sw.WriteLine (indent + "public " + modifiers + CSType + " " + name + " {");
|
||||||
indent += "\t";
|
indent += "\t";
|
||||||
|
|
||||||
if (Getter != null) {
|
if (Getter != null) {
|
||||||
sw.Write(indent + "get ");
|
sw.Write(indent + "get ");
|
||||||
Getter.GenerateBody(gen_info, implementor, "\t");
|
Getter.GenerateBody(gen_info, implementor, "\t");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
} else if (Readable) {
|
} else if (Readable) {
|
||||||
sw.WriteLine(indent + "get {");
|
sw.WriteLine(indent + "get {");
|
||||||
sw.WriteLine(indent + "\tGLib.Value val = " + RawGetter (qpname) + ";");
|
sw.WriteLine(indent + "\tGLib.Value val = " + RawGetter (qpname) + ";");
|
||||||
if (table.IsOpaque (CType) || table.IsBoxed (CType)) {
|
if (table.IsOpaque (CType) || table.IsBoxed (CType)) {
|
||||||
sw.WriteLine(indent + "\t" + CSType + " ret = (" + CSType + ") val;");
|
sw.WriteLine(indent + "\t" + CSType + " ret = (" + CSType + ") val;");
|
||||||
} else if (table.IsInterface (CType)) {
|
} else if (table.IsInterface (CType)) {
|
||||||
// Do we have to dispose the GLib.Object from the GLib.Value?
|
// Do we have to dispose the GLib.Object from the GLib.Value?
|
||||||
sw.WriteLine (indent + "\t{0} ret = {0}Adapter.GetObject ((GLib.Object) val);", CSType);
|
sw.WriteLine (indent + "\t{0} ret = {0}Adapter.GetObject ((GLib.Object) val);", CSType);
|
||||||
} else {
|
} else {
|
||||||
sw.Write(indent + "\t" + CSType + " ret = ");
|
sw.Write(indent + "\t" + CSType + " ret = ");
|
||||||
sw.Write ("(" + CSType + ") ");
|
sw.Write ("(" + CSType + ") ");
|
||||||
if (v_type != "") {
|
if (v_type != "") {
|
||||||
sw.Write(v_type + " ");
|
sw.Write(v_type + " ");
|
||||||
}
|
}
|
||||||
sw.WriteLine("val;");
|
sw.WriteLine("val;");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine(indent + "\tval.Dispose ();");
|
sw.WriteLine(indent + "\tval.Dispose ();");
|
||||||
sw.WriteLine(indent + "\treturn ret;");
|
sw.WriteLine(indent + "\treturn ret;");
|
||||||
sw.WriteLine(indent + "}");
|
sw.WriteLine(indent + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Setter != null) {
|
if (Setter != null) {
|
||||||
sw.Write(indent + "set ");
|
sw.Write(indent + "set ");
|
||||||
Setter.GenerateBody(gen_info, implementor, "\t");
|
Setter.GenerateBody(gen_info, implementor, "\t");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
} else if (Writable) {
|
} else if (Writable) {
|
||||||
sw.WriteLine(indent + "set {");
|
sw.WriteLine(indent + "set {");
|
||||||
sw.Write(indent + "\tGLib.Value val = ");
|
sw.Write(indent + "\tGLib.Value val = ");
|
||||||
if (table.IsBoxed (CType)) {
|
if (table.IsBoxed (CType)) {
|
||||||
sw.WriteLine("(GLib.Value) value;");
|
sw.WriteLine("(GLib.Value) value;");
|
||||||
} else if (table.IsOpaque (CType)) {
|
} else if (table.IsOpaque (CType)) {
|
||||||
sw.WriteLine("new GLib.Value(value, \"{0}\");", CType);
|
sw.WriteLine("new GLib.Value(value, \"{0}\");", CType);
|
||||||
} else {
|
} else {
|
||||||
sw.Write("new GLib.Value(");
|
sw.Write("new GLib.Value(");
|
||||||
if (v_type != "" && !(table.IsObject (CType) || table.IsInterface (CType) || table.IsOpaque (CType))) {
|
if (v_type != "" && !(table.IsObject (CType) || table.IsInterface (CType) || table.IsOpaque (CType))) {
|
||||||
sw.Write(v_type + " ");
|
sw.Write(v_type + " ");
|
||||||
}
|
}
|
||||||
sw.WriteLine("value);");
|
sw.WriteLine("value);");
|
||||||
}
|
}
|
||||||
sw.WriteLine(indent + "\t" + RawSetter (qpname) + ";");
|
sw.WriteLine(indent + "\t" + RawSetter (qpname) + ";");
|
||||||
sw.WriteLine(indent + "\tval.Dispose ();");
|
sw.WriteLine(indent + "\tval.Dispose ();");
|
||||||
sw.WriteLine(indent + "}");
|
sw.WriteLine(indent + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine(indent.Substring (1) + "}");
|
sw.WriteLine(indent.Substring (1) + "}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
Statistics.PropCount++;
|
Statistics.PropCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,194 +1,194 @@
|
|||||||
// GtkSharp.Generation.ReturnValue.cs - The ReturnValue Generatable.
|
// GtkSharp.Generation.ReturnValue.cs - The ReturnValue Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2005 Novell, Inc.
|
// Copyright (c) 2004-2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class ReturnValue {
|
public class ReturnValue {
|
||||||
|
|
||||||
|
|
||||||
bool is_null_term;
|
bool is_null_term;
|
||||||
bool is_array;
|
bool is_array;
|
||||||
bool elements_owned;
|
bool elements_owned;
|
||||||
bool owned;
|
bool owned;
|
||||||
string array_length_param = String.Empty;
|
string array_length_param = String.Empty;
|
||||||
string ctype = String.Empty;
|
string ctype = String.Empty;
|
||||||
string default_value = String.Empty;
|
string default_value = String.Empty;
|
||||||
string element_ctype = String.Empty;
|
string element_ctype = String.Empty;
|
||||||
Parameter count_param;
|
Parameter count_param;
|
||||||
|
|
||||||
public ReturnValue (XmlElement elem)
|
public ReturnValue (XmlElement elem)
|
||||||
{
|
{
|
||||||
if (elem != null) {
|
if (elem != null) {
|
||||||
is_null_term = elem.GetAttributeAsBoolean ("null_term_array");
|
is_null_term = elem.GetAttributeAsBoolean ("null_term_array");
|
||||||
is_array = elem.GetAttributeAsBoolean ("array") || elem.HasAttribute ("array_length_param");
|
is_array = elem.GetAttributeAsBoolean ("array") || elem.HasAttribute ("array_length_param");
|
||||||
array_length_param = elem.GetAttribute ("array_length_param");
|
array_length_param = elem.GetAttribute ("array_length_param");
|
||||||
elements_owned = elem.GetAttributeAsBoolean ("elements_owned");
|
elements_owned = elem.GetAttributeAsBoolean ("elements_owned");
|
||||||
owned = elem.GetAttributeAsBoolean ("owned");
|
owned = elem.GetAttributeAsBoolean ("owned");
|
||||||
ctype = elem.GetAttribute("type");
|
ctype = elem.GetAttribute("type");
|
||||||
default_value = elem.GetAttribute ("default_value");
|
default_value = elem.GetAttribute ("default_value");
|
||||||
element_ctype = elem.GetAttribute ("element_type");
|
element_ctype = elem.GetAttribute ("element_type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Parameter CountParameter {
|
public Parameter CountParameter {
|
||||||
get { return count_param; }
|
get { return count_param; }
|
||||||
set { count_param = value; }
|
set { count_param = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CountParameterName {
|
public string CountParameterName {
|
||||||
get { return array_length_param; }
|
get { return array_length_param; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CType {
|
public string CType {
|
||||||
get {
|
get {
|
||||||
return ctype;
|
return ctype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CSType {
|
public string CSType {
|
||||||
get {
|
get {
|
||||||
if (IGen == null)
|
if (IGen == null)
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
|
||||||
if (ElementType != String.Empty)
|
if (ElementType != String.Empty)
|
||||||
return ElementType + "[]";
|
return ElementType + "[]";
|
||||||
|
|
||||||
return IGen.QualifiedName + (is_array || is_null_term ? "[]" : String.Empty);
|
return IGen.QualifiedName + (is_array || is_null_term ? "[]" : String.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DefaultValue {
|
public string DefaultValue {
|
||||||
get {
|
get {
|
||||||
if (default_value != null && default_value.Length > 0)
|
if (default_value != null && default_value.Length > 0)
|
||||||
return default_value;
|
return default_value;
|
||||||
if (IGen == null)
|
if (IGen == null)
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
return IGen.DefaultValue;
|
return IGen.DefaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string ElementType {
|
string ElementType {
|
||||||
get {
|
get {
|
||||||
if (element_ctype.Length > 0)
|
if (element_ctype.Length > 0)
|
||||||
return SymbolTable.Table.GetCSType (element_ctype);
|
return SymbolTable.Table.GetCSType (element_ctype);
|
||||||
|
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IGeneratable igen;
|
IGeneratable igen;
|
||||||
public IGeneratable IGen {
|
public IGeneratable IGen {
|
||||||
get {
|
get {
|
||||||
if (igen == null)
|
if (igen == null)
|
||||||
igen = SymbolTable.Table [CType];
|
igen = SymbolTable.Table [CType];
|
||||||
return igen;
|
return igen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsVoid {
|
public bool IsVoid {
|
||||||
get {
|
get {
|
||||||
return CSType == "void";
|
return CSType == "void";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string MarshalType {
|
public string MarshalType {
|
||||||
get {
|
get {
|
||||||
if (IGen == null)
|
if (IGen == null)
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
else if (is_array || is_null_term)
|
else if (is_array || is_null_term)
|
||||||
return "IntPtr";
|
return "IntPtr";
|
||||||
return IGen.MarshalType;
|
return IGen.MarshalType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToNativeType {
|
public string ToNativeType {
|
||||||
get {
|
get {
|
||||||
if (IGen == null)
|
if (IGen == null)
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
return IGen.MarshalType + (is_array || is_null_term ? "[]" : String.Empty);
|
return IGen.MarshalType + (is_array || is_null_term ? "[]" : String.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FromNative (string var)
|
public string FromNative (string var)
|
||||||
{
|
{
|
||||||
if (IGen == null)
|
if (IGen == null)
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
|
||||||
if (ElementType != String.Empty) {
|
if (ElementType != String.Empty) {
|
||||||
string args = (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
|
string args = (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
|
||||||
if (IGen.QualifiedName == "GLib.PtrArray")
|
if (IGen.QualifiedName == "GLib.PtrArray")
|
||||||
return String.Format ("({0}[]) GLib.Marshaller.PtrArrayToArray ({1}, {2}, typeof({0}))", ElementType, var, args);
|
return String.Format ("({0}[]) GLib.Marshaller.PtrArrayToArray ({1}, {2}, typeof({0}))", ElementType, var, args);
|
||||||
else
|
else
|
||||||
return String.Format ("({0}[]) GLib.Marshaller.ListPtrToArray ({1}, typeof({2}), {3}, typeof({4}))", ElementType, var, IGen.QualifiedName, args, element_ctype == "gfilename*" ? "GLib.ListBase.FilenameString" : ElementType);
|
return String.Format ("({0}[]) GLib.Marshaller.ListPtrToArray ({1}, typeof({2}), {3}, typeof({4}))", ElementType, var, IGen.QualifiedName, args, element_ctype == "gfilename*" ? "GLib.ListBase.FilenameString" : ElementType);
|
||||||
} else if (IGen is IOwnable)
|
} else if (IGen is IOwnable)
|
||||||
return ((IOwnable)IGen).FromNative (var, owned);
|
return ((IOwnable)IGen).FromNative (var, owned);
|
||||||
else if (is_null_term)
|
else if (is_null_term)
|
||||||
return String.Format ("GLib.Marshaller.NullTermPtrToStringArray ({0}, {1})", var, owned ? "true" : "false");
|
return String.Format ("GLib.Marshaller.NullTermPtrToStringArray ({0}, {1})", var, owned ? "true" : "false");
|
||||||
else if (is_array)
|
else if (is_array)
|
||||||
return String.Format ("({0}) GLib.Marshaller.ArrayPtrToArray ({1}, typeof ({2}), (int){3}native_{4}, true)", CSType, var, IGen.QualifiedName, CountParameter.CSType == "int" ? String.Empty : "(" + CountParameter.CSType + ")", CountParameter.Name);
|
return String.Format ("({0}) GLib.Marshaller.ArrayPtrToArray ({1}, typeof ({2}), (int){3}native_{4}, true)", CSType, var, IGen.QualifiedName, CountParameter.CSType == "int" ? String.Empty : "(" + CountParameter.CSType + ")", CountParameter.Name);
|
||||||
else
|
else
|
||||||
return IGen.FromNative (var);
|
return IGen.FromNative (var);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToNative (string var)
|
public string ToNative (string var)
|
||||||
{
|
{
|
||||||
if (IGen == null)
|
if (IGen == null)
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
|
||||||
if (ElementType.Length > 0) {
|
if (ElementType.Length > 0) {
|
||||||
string args = ", typeof (" + ElementType + "), " + (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
|
string args = ", typeof (" + ElementType + "), " + (owned ? "true" : "false") + ", " + (elements_owned ? "true" : "false");
|
||||||
var = "new " + IGen.QualifiedName + "(" + var + args + ")";
|
var = "new " + IGen.QualifiedName + "(" + var + args + ")";
|
||||||
} else if (is_null_term)
|
} else if (is_null_term)
|
||||||
return String.Format ("GLib.Marshaller.StringArrayToNullTermPointer ({0})", var);
|
return String.Format ("GLib.Marshaller.StringArrayToNullTermPointer ({0})", var);
|
||||||
else if (is_array)
|
else if (is_array)
|
||||||
return String.Format ("GLib.Marshaller.ArrayToArrayPtr ({0})", var);
|
return String.Format ("GLib.Marshaller.ArrayToArrayPtr ({0})", var);
|
||||||
|
|
||||||
if (IGen is IManualMarshaler)
|
if (IGen is IManualMarshaler)
|
||||||
return (IGen as IManualMarshaler).AllocNative (var);
|
return (IGen as IManualMarshaler).AllocNative (var);
|
||||||
else if (IGen is ObjectGen && owned)
|
else if (IGen is ObjectGen && owned)
|
||||||
return var + " == null ? IntPtr.Zero : " + var + ".OwnedHandle";
|
return var + " == null ? IntPtr.Zero : " + var + ".OwnedHandle";
|
||||||
else if (IGen is OpaqueGen && owned)
|
else if (IGen is OpaqueGen && owned)
|
||||||
return var + " == null ? IntPtr.Zero : " + var + ".OwnedCopy";
|
return var + " == null ? IntPtr.Zero : " + var + ".OwnedCopy";
|
||||||
else
|
else
|
||||||
return IGen.CallByName (var);
|
return IGen.CallByName (var);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Validate (LogWriter log)
|
public bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
if (MarshalType == "" || CSType == "") {
|
if (MarshalType == "" || CSType == "") {
|
||||||
log.Warn ("Unknown return type: {0}", CType);
|
log.Warn ("Unknown return type: {0}", CType);
|
||||||
return false;
|
return false;
|
||||||
} else if ((CSType == "GLib.List" || CSType == "GLib.SList") && String.IsNullOrEmpty (ElementType))
|
} else if ((CSType == "GLib.List" || CSType == "GLib.SList") && String.IsNullOrEmpty (ElementType))
|
||||||
log.Warn ("Returns {0} with unknown element type. Add element_type attribute with gapi-fixup.", CType);
|
log.Warn ("Returns {0} with unknown element type. Add element_type attribute with gapi-fixup.", CType);
|
||||||
|
|
||||||
if (is_array && !is_null_term && String.IsNullOrEmpty (array_length_param)) {
|
if (is_array && !is_null_term && String.IsNullOrEmpty (array_length_param)) {
|
||||||
log.Warn ("Returns an array with undeterminable length. Add null_term_array or array_length_param attribute with gapi-fixup.");
|
log.Warn ("Returns an array with undeterminable length. Add null_term_array or array_length_param attribute with gapi-fixup.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,330 +1,330 @@
|
|||||||
// GtkSharp.Generation.Signal.cs - The Signal Generatable.
|
// GtkSharp.Generation.Signal.cs - The Signal Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2003-2005 Novell, Inc.
|
// Copyright (c) 2003-2005 Novell, Inc.
|
||||||
// Copyright (c) 2007 Novell, Inc.
|
// Copyright (c) 2007 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class Signal {
|
public class Signal {
|
||||||
|
|
||||||
bool marshaled;
|
bool marshaled;
|
||||||
string name;
|
string name;
|
||||||
XmlElement elem;
|
XmlElement elem;
|
||||||
ReturnValue retval;
|
ReturnValue retval;
|
||||||
Parameters parms;
|
Parameters parms;
|
||||||
ObjectBase container_type;
|
ObjectBase container_type;
|
||||||
|
|
||||||
public Signal (XmlElement elem, ObjectBase container_type)
|
public Signal (XmlElement elem, ObjectBase container_type)
|
||||||
{
|
{
|
||||||
this.elem = elem;
|
this.elem = elem;
|
||||||
name = elem.GetAttribute ("name");
|
name = elem.GetAttribute ("name");
|
||||||
marshaled = elem.GetAttribute ("manual") == "true";
|
marshaled = elem.GetAttribute ("manual") == "true";
|
||||||
retval = new ReturnValue (elem ["return-type"]);
|
retval = new ReturnValue (elem ["return-type"]);
|
||||||
parms = new Parameters (elem["parameters"], container_type.ParserVersion == 1 ? true : false);
|
parms = new Parameters (elem["parameters"], container_type.ParserVersion == 1 ? true : false);
|
||||||
this.container_type = container_type;
|
this.container_type = container_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Marshaled {
|
bool Marshaled {
|
||||||
get { return marshaled; }
|
get { return marshaled; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
name = value;
|
name = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Validate (LogWriter log)
|
public bool Validate (LogWriter log)
|
||||||
{
|
{
|
||||||
log.Member = Name;
|
log.Member = Name;
|
||||||
if (Name == "") {
|
if (Name == "") {
|
||||||
log.Warn ("Nameless signal found. Add name attribute with fixup.");
|
log.Warn ("Nameless signal found. Add name attribute with fixup.");
|
||||||
Statistics.ThrottledCount++;
|
Statistics.ThrottledCount++;
|
||||||
return false;
|
return false;
|
||||||
} else if (!parms.Validate (log) || !retval.Validate (log)) {
|
} else if (!parms.Validate (log) || !retval.Validate (log)) {
|
||||||
Statistics.ThrottledCount++;
|
Statistics.ThrottledCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateDecl (StreamWriter sw)
|
public void GenerateDecl (StreamWriter sw)
|
||||||
{
|
{
|
||||||
if (elem.GetAttributeAsBoolean ("new_flag") || (container_type != null && container_type.GetSignalRecursively (Name) != null))
|
if (elem.GetAttributeAsBoolean ("new_flag") || (container_type != null && container_type.GetSignalRecursively (Name) != null))
|
||||||
sw.Write("new ");
|
sw.Write("new ");
|
||||||
|
|
||||||
sw.WriteLine ("\t\tevent " + EventHandlerQualifiedName + " " + Name + ";");
|
sw.WriteLine ("\t\tevent " + EventHandlerQualifiedName + " " + Name + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CName {
|
public string CName {
|
||||||
get {
|
get {
|
||||||
return "\"" + elem.GetAttribute("cname") + "\"";
|
return "\"" + elem.GetAttribute("cname") + "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string CallbackSig {
|
string CallbackSig {
|
||||||
get {
|
get {
|
||||||
string result = "";
|
string result = "";
|
||||||
for (int i = 0; i < parms.Count; i++) {
|
for (int i = 0; i < parms.Count; i++) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
result += ", ";
|
result += ", ";
|
||||||
|
|
||||||
Parameter p = parms [i];
|
Parameter p = parms [i];
|
||||||
if (p.PassAs != "" && !(p.Generatable is StructBase))
|
if (p.PassAs != "" && !(p.Generatable is StructBase))
|
||||||
result += p.PassAs + " ";
|
result += p.PassAs + " ";
|
||||||
result += (p.MarshalType + " arg" + i);
|
result += (p.MarshalType + " arg" + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string CallbackName {
|
string CallbackName {
|
||||||
get { return Name + "SignalCallback"; }
|
get { return Name + "SignalCallback"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
string DelegateName {
|
string DelegateName {
|
||||||
get { return Name + "SignalDelegate"; }
|
get { return Name + "SignalDelegate"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private string EventArgsName {
|
private string EventArgsName {
|
||||||
get {
|
get {
|
||||||
if (IsEventHandler)
|
if (IsEventHandler)
|
||||||
return "EventArgs";
|
return "EventArgs";
|
||||||
else
|
else
|
||||||
return Name + "Args";
|
return Name + "Args";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string EventArgsQualifiedName {
|
private string EventArgsQualifiedName {
|
||||||
get {
|
get {
|
||||||
if (IsEventHandler)
|
if (IsEventHandler)
|
||||||
return "System.EventArgs";
|
return "System.EventArgs";
|
||||||
else
|
else
|
||||||
return container_type.NS + "." + Name + "Args";
|
return container_type.NS + "." + Name + "Args";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string EventHandlerName {
|
private string EventHandlerName {
|
||||||
get {
|
get {
|
||||||
if (IsEventHandler)
|
if (IsEventHandler)
|
||||||
return "EventHandler";
|
return "EventHandler";
|
||||||
else if (SymbolTable.Table [container_type.NS + Name + "Handler"] != null)
|
else if (SymbolTable.Table [container_type.NS + Name + "Handler"] != null)
|
||||||
return Name + "EventHandler";
|
return Name + "EventHandler";
|
||||||
else
|
else
|
||||||
return Name + "Handler";
|
return Name + "Handler";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string EventHandlerQualifiedName {
|
private string EventHandlerQualifiedName {
|
||||||
get {
|
get {
|
||||||
if (IsEventHandler)
|
if (IsEventHandler)
|
||||||
return "System.EventHandler";
|
return "System.EventHandler";
|
||||||
else
|
else
|
||||||
return container_type.NS + "." + EventHandlerName;
|
return container_type.NS + "." + EventHandlerName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsEventHandler {
|
private bool IsEventHandler {
|
||||||
get {
|
get {
|
||||||
return retval.CSType == "void" && parms.Count == 0;
|
return retval.CSType == "void" && parms.Count == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GenArgsInitialization (StreamWriter sw)
|
public string GenArgsInitialization (StreamWriter sw)
|
||||||
{
|
{
|
||||||
if (parms.Count > 0)
|
if (parms.Count > 0)
|
||||||
sw.WriteLine("\t\t\t\targs.Args = new object[" + parms.Count + "];");
|
sw.WriteLine("\t\t\t\targs.Args = new object[" + parms.Count + "];");
|
||||||
string finish = "";
|
string finish = "";
|
||||||
for (int idx = 0; idx < parms.Count; idx++) {
|
for (int idx = 0; idx < parms.Count; idx++) {
|
||||||
Parameter p = parms [idx];
|
Parameter p = parms [idx];
|
||||||
IGeneratable igen = p.Generatable;
|
IGeneratable igen = p.Generatable;
|
||||||
if (p.PassAs != "out") {
|
if (p.PassAs != "out") {
|
||||||
if (igen is ManualGen) {
|
if (igen is ManualGen) {
|
||||||
sw.WriteLine("\t\t\t\tif (arg{0} == IntPtr.Zero)", idx);
|
sw.WriteLine("\t\t\t\tif (arg{0} == IntPtr.Zero)", idx);
|
||||||
sw.WriteLine("\t\t\t\t\targs.Args[{0}] = null;", idx);
|
sw.WriteLine("\t\t\t\t\targs.Args[{0}] = null;", idx);
|
||||||
sw.WriteLine("\t\t\t\telse {");
|
sw.WriteLine("\t\t\t\telse {");
|
||||||
sw.WriteLine("\t\t\t\t\targs.Args[" + idx + "] = " + p.FromNative ("arg" + idx) + ";");
|
sw.WriteLine("\t\t\t\t\targs.Args[" + idx + "] = " + p.FromNative ("arg" + idx) + ";");
|
||||||
sw.WriteLine("\t\t\t\t}");
|
sw.WriteLine("\t\t\t\t}");
|
||||||
} else
|
} else
|
||||||
sw.WriteLine("\t\t\t\targs.Args[" + idx + "] = " + p.FromNative ("arg" + idx) + ";");
|
sw.WriteLine("\t\t\t\targs.Args[" + idx + "] = " + p.FromNative ("arg" + idx) + ";");
|
||||||
}
|
}
|
||||||
if ((igen is StructBase || igen is ByRefGen) && p.PassAs != "")
|
if ((igen is StructBase || igen is ByRefGen) && p.PassAs != "")
|
||||||
finish += "\t\t\t\tif (arg" + idx + " != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (args.Args[" + idx + "], arg" + idx + ", false);\n";
|
finish += "\t\t\t\tif (arg" + idx + " != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (args.Args[" + idx + "], arg" + idx + ", false);\n";
|
||||||
else if (igen is IManualMarshaler && p.PassAs != "")
|
else if (igen is IManualMarshaler && p.PassAs != "")
|
||||||
finish += String.Format ("\t\t\t\targ{0} = {1};\n", idx, (igen as IManualMarshaler).AllocNative ("args.Args[" + idx + "]"));
|
finish += String.Format ("\t\t\t\targ{0} = {1};\n", idx, (igen as IManualMarshaler).AllocNative ("args.Args[" + idx + "]"));
|
||||||
else if (p.PassAs != "")
|
else if (p.PassAs != "")
|
||||||
finish += "\t\t\t\targ" + idx + " = " + igen.CallByName ("((" + p.CSType + ")args.Args[" + idx + "])") + ";\n";
|
finish += "\t\t\t\targ" + idx + " = " + igen.CallByName ("((" + p.CSType + ")args.Args[" + idx + "])") + ";\n";
|
||||||
}
|
}
|
||||||
return finish;
|
return finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenArgsCleanup (StreamWriter sw, string finish)
|
public void GenArgsCleanup (StreamWriter sw, string finish)
|
||||||
{
|
{
|
||||||
if (retval.IsVoid && finish.Length == 0)
|
if (retval.IsVoid && finish.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sw.WriteLine("\n\t\t\ttry {");
|
sw.WriteLine("\n\t\t\ttry {");
|
||||||
sw.Write (finish);
|
sw.Write (finish);
|
||||||
if (!retval.IsVoid) {
|
if (!retval.IsVoid) {
|
||||||
if (retval.CSType == "bool") {
|
if (retval.CSType == "bool") {
|
||||||
sw.WriteLine ("\t\t\t\tif (args.RetVal == null)");
|
sw.WriteLine ("\t\t\t\tif (args.RetVal == null)");
|
||||||
sw.WriteLine ("\t\t\t\t\treturn false;");
|
sw.WriteLine ("\t\t\t\t\treturn false;");
|
||||||
}
|
}
|
||||||
sw.WriteLine ("\t\t\t\treturn {0};", retval.ToNative (String.Format ("(({0}) args.RetVal)", retval.CSType)));
|
sw.WriteLine ("\t\t\t\treturn {0};", retval.ToNative (String.Format ("(({0}) args.RetVal)", retval.CSType)));
|
||||||
}
|
}
|
||||||
sw.WriteLine("\t\t\t} catch (Exception) {");
|
sw.WriteLine("\t\t\t} catch (Exception) {");
|
||||||
sw.WriteLine ("\t\t\t\tException ex = new Exception (\"args.RetVal or 'out' property unset or set to incorrect type in " + EventHandlerQualifiedName + " callback\");");
|
sw.WriteLine ("\t\t\t\tException ex = new Exception (\"args.RetVal or 'out' property unset or set to incorrect type in " + EventHandlerQualifiedName + " callback\");");
|
||||||
sw.WriteLine("\t\t\t\tGLib.ExceptionManager.RaiseUnhandledException (ex, true);");
|
sw.WriteLine("\t\t\t\tGLib.ExceptionManager.RaiseUnhandledException (ex, true);");
|
||||||
|
|
||||||
sw.WriteLine ("\t\t\t\t// NOTREACHED: above call doesn't return.");
|
sw.WriteLine ("\t\t\t\t// NOTREACHED: above call doesn't return.");
|
||||||
sw.WriteLine ("\t\t\t\tthrow ex;");
|
sw.WriteLine ("\t\t\t\tthrow ex;");
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenCallback (StreamWriter sw)
|
public void GenCallback (StreamWriter sw)
|
||||||
{
|
{
|
||||||
if (IsEventHandler)
|
if (IsEventHandler)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string native_signature = "IntPtr inst";
|
string native_signature = "IntPtr inst";
|
||||||
if (parms.Count > 0)
|
if (parms.Count > 0)
|
||||||
native_signature += ", " + CallbackSig;
|
native_signature += ", " + CallbackSig;
|
||||||
native_signature += ", IntPtr gch";
|
native_signature += ", IntPtr gch";
|
||||||
|
|
||||||
sw.WriteLine ("\t\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
|
sw.WriteLine ("\t\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
|
||||||
sw.WriteLine ("\t\tdelegate {0} {1} ({2});", retval.ToNativeType, DelegateName, native_signature);
|
sw.WriteLine ("\t\tdelegate {0} {1} ({2});", retval.ToNativeType, DelegateName, native_signature);
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tstatic {0} {1} ({2})", retval.ToNativeType, CallbackName, native_signature);
|
sw.WriteLine ("\t\tstatic {0} {1} ({2})", retval.ToNativeType, CallbackName, native_signature);
|
||||||
sw.WriteLine("\t\t{");
|
sw.WriteLine("\t\t{");
|
||||||
sw.WriteLine("\t\t\t{0} args = new {0} ();", EventArgsQualifiedName);
|
sw.WriteLine("\t\t\t{0} args = new {0} ();", EventArgsQualifiedName);
|
||||||
sw.WriteLine("\t\t\ttry {");
|
sw.WriteLine("\t\t\ttry {");
|
||||||
sw.WriteLine("\t\t\t\tGLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;");
|
sw.WriteLine("\t\t\t\tGLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;");
|
||||||
sw.WriteLine("\t\t\t\tif (sig == null)");
|
sw.WriteLine("\t\t\t\tif (sig == null)");
|
||||||
sw.WriteLine("\t\t\t\t\tthrow new Exception(\"Unknown signal GC handle received \" + gch);");
|
sw.WriteLine("\t\t\t\t\tthrow new Exception(\"Unknown signal GC handle received \" + gch);");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
string finish = GenArgsInitialization (sw);
|
string finish = GenArgsInitialization (sw);
|
||||||
sw.WriteLine("\t\t\t\t{0} handler = ({0}) sig.Handler;", EventHandlerQualifiedName);
|
sw.WriteLine("\t\t\t\t{0} handler = ({0}) sig.Handler;", EventHandlerQualifiedName);
|
||||||
sw.WriteLine("\t\t\t\thandler (GLib.Object.GetObject (inst), args);");
|
sw.WriteLine("\t\t\t\thandler (GLib.Object.GetObject (inst), args);");
|
||||||
sw.WriteLine("\t\t\t} catch (Exception e) {");
|
sw.WriteLine("\t\t\t} catch (Exception e) {");
|
||||||
sw.WriteLine("\t\t\t\tGLib.ExceptionManager.RaiseUnhandledException (e, false);");
|
sw.WriteLine("\t\t\t\tGLib.ExceptionManager.RaiseUnhandledException (e, false);");
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
GenArgsCleanup (sw, finish);
|
GenArgsCleanup (sw, finish);
|
||||||
sw.WriteLine("\t\t}");
|
sw.WriteLine("\t\t}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool NeedNew (ObjectBase implementor)
|
private bool NeedNew (ObjectBase implementor)
|
||||||
{
|
{
|
||||||
return elem.GetAttributeAsBoolean ("new_flag") ||
|
return elem.GetAttributeAsBoolean ("new_flag") ||
|
||||||
(container_type != null && container_type.GetSignalRecursively (Name) != null) ||
|
(container_type != null && container_type.GetSignalRecursively (Name) != null) ||
|
||||||
(implementor != null && implementor.GetSignalRecursively (Name) != null);
|
(implementor != null && implementor.GetSignalRecursively (Name) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenEventHandler (GenerationInfo gen_info)
|
public void GenEventHandler (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
if (IsEventHandler)
|
if (IsEventHandler)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string ns = container_type.NS;
|
string ns = container_type.NS;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.OpenStream (EventHandlerName);
|
StreamWriter sw = gen_info.OpenStream (EventHandlerName);
|
||||||
|
|
||||||
sw.WriteLine ("namespace " + ns + " {");
|
sw.WriteLine ("namespace " + ns + " {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
|
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tpublic delegate void " + EventHandlerName + "(object o, " + EventArgsName + " args);");
|
sw.WriteLine ("\tpublic delegate void " + EventHandlerName + "(object o, " + EventArgsName + " args);");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tpublic class " + EventArgsName + " : GLib.SignalArgs {");
|
sw.WriteLine ("\tpublic class " + EventArgsName + " : GLib.SignalArgs {");
|
||||||
for (int i = 0; i < parms.Count; i++) {
|
for (int i = 0; i < parms.Count; i++) {
|
||||||
sw.WriteLine ("\t\tpublic " + parms[i].CSType + " " + parms[i].StudlyName + "{");
|
sw.WriteLine ("\t\tpublic " + parms[i].CSType + " " + parms[i].StudlyName + "{");
|
||||||
if (parms[i].PassAs != "out") {
|
if (parms[i].PassAs != "out") {
|
||||||
sw.WriteLine ("\t\t\tget {");
|
sw.WriteLine ("\t\t\tget {");
|
||||||
if (SymbolTable.Table.IsInterface (parms [i].CType))
|
if (SymbolTable.Table.IsInterface (parms [i].CType))
|
||||||
sw.WriteLine ("\t\t\t\treturn {0}Adapter.GetObject (Args [{1}] as GLib.Object);", parms [i].CSType, i);
|
sw.WriteLine ("\t\t\t\treturn {0}Adapter.GetObject (Args [{1}] as GLib.Object);", parms [i].CSType, i);
|
||||||
else
|
else
|
||||||
sw.WriteLine ("\t\t\t\treturn ({0}) Args [{1}];", parms [i].CSType, i);
|
sw.WriteLine ("\t\t\t\treturn ({0}) Args [{1}];", parms [i].CSType, i);
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
}
|
}
|
||||||
if (parms[i].PassAs != "") {
|
if (parms[i].PassAs != "") {
|
||||||
sw.WriteLine ("\t\t\tset {");
|
sw.WriteLine ("\t\t\tset {");
|
||||||
if (SymbolTable.Table.IsInterface (parms [i].CType))
|
if (SymbolTable.Table.IsInterface (parms [i].CType))
|
||||||
sw.WriteLine ("\t\t\t\tArgs [{0}] = value is {1}Adapter ? (value as {1}Adapter).Implementor : value;", i, parms [i].CSType);
|
sw.WriteLine ("\t\t\t\tArgs [{0}] = value is {1}Adapter ? (value as {1}Adapter).Implementor : value;", i, parms [i].CSType);
|
||||||
else
|
else
|
||||||
sw.WriteLine ("\t\t\t\tArgs[" + i + "] = (" + parms[i].CSType + ")value;");
|
sw.WriteLine ("\t\t\t\tArgs[" + i + "] = (" + parms[i].CSType + ")value;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
}
|
}
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
}
|
}
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenEvent (StreamWriter sw, ObjectBase implementor, string target)
|
public void GenEvent (StreamWriter sw, ObjectBase implementor, string target)
|
||||||
{
|
{
|
||||||
string args_type = IsEventHandler ? "" : ", typeof (" + EventArgsQualifiedName + ")";
|
string args_type = IsEventHandler ? "" : ", typeof (" + EventArgsQualifiedName + ")";
|
||||||
|
|
||||||
if (Marshaled) {
|
if (Marshaled) {
|
||||||
GenCallback (sw);
|
GenCallback (sw);
|
||||||
args_type = ", new " + DelegateName + "(" + CallbackName + ")";
|
args_type = ", new " + DelegateName + "(" + CallbackName + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.WriteLine("\t\t[GLib.Signal("+ CName + ")]");
|
sw.WriteLine("\t\t[GLib.Signal("+ CName + ")]");
|
||||||
sw.Write("\t\tpublic ");
|
sw.Write("\t\tpublic ");
|
||||||
if (NeedNew (implementor))
|
if (NeedNew (implementor))
|
||||||
sw.Write("new ");
|
sw.Write("new ");
|
||||||
sw.WriteLine("event " + EventHandlerQualifiedName + " " + Name + " {");
|
sw.WriteLine("event " + EventHandlerQualifiedName + " " + Name + " {");
|
||||||
sw.WriteLine("\t\t\tadd {");
|
sw.WriteLine("\t\t\tadd {");
|
||||||
sw.WriteLine("\t\t\t\t{0}.AddSignalHandler ({1}, value{2});", target, CName, args_type);
|
sw.WriteLine("\t\t\t\t{0}.AddSignalHandler ({1}, value{2});", target, CName, args_type);
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
sw.WriteLine("\t\t\tremove {");
|
sw.WriteLine("\t\t\tremove {");
|
||||||
sw.WriteLine("\t\t\t\t{0}.RemoveSignalHandler ({1}, value);", target, CName);
|
sw.WriteLine("\t\t\t\t{0}.RemoveSignalHandler ({1}, value);", target, CName);
|
||||||
sw.WriteLine("\t\t\t}");
|
sw.WriteLine("\t\t\t}");
|
||||||
sw.WriteLine("\t\t}");
|
sw.WriteLine("\t\t}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate (GenerationInfo gen_info, ObjectBase implementor)
|
public void Generate (GenerationInfo gen_info, ObjectBase implementor)
|
||||||
{
|
{
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
|
|
||||||
if (implementor == null)
|
if (implementor == null)
|
||||||
GenEventHandler (gen_info);
|
GenEventHandler (gen_info);
|
||||||
|
|
||||||
GenEvent (sw, implementor, "this");
|
GenEvent (sw, implementor, "this");
|
||||||
|
|
||||||
Statistics.SignalCount++;
|
Statistics.SignalCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,123 +1,123 @@
|
|||||||
// GtkSharp.Generation.Signature.cs - The Signature Generation Class.
|
// GtkSharp.Generation.Signature.cs - The Signature Generation Class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@ximian.com>
|
// Author: Mike Kestner <mkestner@ximian.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003-2004 Novell, Inc.
|
// Copyright (c) 2003-2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class Signature {
|
public class Signature {
|
||||||
|
|
||||||
private ArrayList parms = new ArrayList ();
|
private ArrayList parms = new ArrayList ();
|
||||||
|
|
||||||
public Signature (Parameters parms)
|
public Signature (Parameters parms)
|
||||||
{
|
{
|
||||||
foreach (Parameter p in parms) {
|
foreach (Parameter p in parms) {
|
||||||
if (!parms.IsHidden (p))
|
if (!parms.IsHidden (p))
|
||||||
this.parms.Add (p);
|
this.parms.Add (p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString ()
|
public override string ToString ()
|
||||||
{
|
{
|
||||||
if (parms.Count == 0)
|
if (parms.Count == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
string[] result = new string [parms.Count];
|
string[] result = new string [parms.Count];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
foreach (Parameter p in parms) {
|
foreach (Parameter p in parms) {
|
||||||
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
||||||
result [i++] += p.CSType + " " + p.Name;
|
result [i++] += p.CSType + " " + p.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.Join (", ", result);
|
return String.Join (", ", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Types {
|
public string Types {
|
||||||
get {
|
get {
|
||||||
if (parms.Count == 0)
|
if (parms.Count == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
string[] result = new string [parms.Count];
|
string[] result = new string [parms.Count];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
foreach (Parameter p in parms)
|
foreach (Parameter p in parms)
|
||||||
result [i++] = p.CSType;
|
result [i++] = p.CSType;
|
||||||
|
|
||||||
return String.Join (":", result);
|
return String.Join (":", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsAccessor {
|
public bool IsAccessor {
|
||||||
get {
|
get {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (Parameter p in parms) {
|
foreach (Parameter p in parms) {
|
||||||
if (p.PassAs == "out")
|
if (p.PassAs == "out")
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count > 1)
|
if (count > 1)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return count == 1;
|
return count == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AccessorType {
|
public string AccessorType {
|
||||||
get {
|
get {
|
||||||
foreach (Parameter p in parms)
|
foreach (Parameter p in parms)
|
||||||
if (p.PassAs == "out")
|
if (p.PassAs == "out")
|
||||||
return p.CSType;
|
return p.CSType;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AccessorName {
|
public string AccessorName {
|
||||||
get {
|
get {
|
||||||
foreach (Parameter p in parms)
|
foreach (Parameter p in parms)
|
||||||
if (p.PassAs == "out")
|
if (p.PassAs == "out")
|
||||||
return p.Name;
|
return p.Name;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AsAccessor {
|
public string AsAccessor {
|
||||||
get {
|
get {
|
||||||
string[] result = new string [parms.Count - 1];
|
string[] result = new string [parms.Count - 1];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
foreach (Parameter p in parms) {
|
foreach (Parameter p in parms) {
|
||||||
if (p.PassAs == "out")
|
if (p.PassAs == "out")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
||||||
result [i++] += p.CSType + " " + p.Name;
|
result [i++] += p.CSType + " " + p.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.Join (", ", result);
|
return String.Join (", ", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,99 +1,99 @@
|
|||||||
// GtkSharp.Generation.SimpleBase.cs - base class for marshaling non-generated types.
|
// GtkSharp.Generation.SimpleBase.cs - base class for marshaling non-generated types.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public abstract class SimpleBase : IGeneratable {
|
public abstract class SimpleBase : IGeneratable {
|
||||||
|
|
||||||
string type;
|
string type;
|
||||||
string ctype;
|
string ctype;
|
||||||
string ns = String.Empty;
|
string ns = String.Empty;
|
||||||
string default_value = String.Empty;
|
string default_value = String.Empty;
|
||||||
|
|
||||||
public SimpleBase (string ctype, string type, string default_value)
|
public SimpleBase (string ctype, string type, string default_value)
|
||||||
{
|
{
|
||||||
string[] toks = type.Split('.');
|
string[] toks = type.Split('.');
|
||||||
this.ctype = ctype;
|
this.ctype = ctype;
|
||||||
this.type = toks[toks.Length - 1];
|
this.type = toks[toks.Length - 1];
|
||||||
if (toks.Length > 2)
|
if (toks.Length > 2)
|
||||||
this.ns = String.Join (".", toks, 0, toks.Length - 1);
|
this.ns = String.Join (".", toks, 0, toks.Length - 1);
|
||||||
else if (toks.Length == 2)
|
else if (toks.Length == 2)
|
||||||
this.ns = toks[0];
|
this.ns = toks[0];
|
||||||
this.default_value = default_value;
|
this.default_value = default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CName {
|
public string CName {
|
||||||
get {
|
get {
|
||||||
return ctype;
|
return ctype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string QualifiedName {
|
public string QualifiedName {
|
||||||
get {
|
get {
|
||||||
return ns == String.Empty ? type : ns + "." + type;
|
return ns == String.Empty ? type : ns + "." + type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string MarshalType {
|
public virtual string MarshalType {
|
||||||
get {
|
get {
|
||||||
return QualifiedName;
|
return QualifiedName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string DefaultValue {
|
public virtual string DefaultValue {
|
||||||
get {
|
get {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string CallByName (string var)
|
public virtual string CallByName (string var)
|
||||||
{
|
{
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string FromNative(string var)
|
public virtual string FromNative(string var)
|
||||||
{
|
{
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Validate ()
|
public bool Validate ()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate ()
|
public void Generate ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate (GenerationInfo gen_info)
|
public void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
// GtkSharp.Generation.SimpleGen.cs - The Simple type Generatable.
|
// GtkSharp.Generation.SimpleGen.cs - The Simple type Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003 Mike Kestner
|
// Copyright (c) 2003 Mike Kestner
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class SimpleGen : SimpleBase {
|
public class SimpleGen : SimpleBase {
|
||||||
public SimpleGen (string ctype, string type, string default_value) : base (ctype, type, default_value) {}
|
public SimpleGen (string ctype, string type, string default_value) : base (ctype, type, default_value) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,197 +1,197 @@
|
|||||||
// Statistics.cs : Generation statistics class implementation
|
// Statistics.cs : Generation statistics class implementation
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@ximian.com>
|
// Author: Mike Kestner <mkestner@ximian.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2002 Mike Kestner
|
// Copyright (c) 2002 Mike Kestner
|
||||||
// Copyright (c) 2004 Novell, Inc.
|
// Copyright (c) 2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
public class Statistics {
|
public class Statistics {
|
||||||
|
|
||||||
static int cbs = 0;
|
static int cbs = 0;
|
||||||
static int enums = 0;
|
static int enums = 0;
|
||||||
static int objects = 0;
|
static int objects = 0;
|
||||||
static int structs = 0;
|
static int structs = 0;
|
||||||
static int boxed = 0;
|
static int boxed = 0;
|
||||||
static int opaques = 0;
|
static int opaques = 0;
|
||||||
static int interfaces = 0;
|
static int interfaces = 0;
|
||||||
static int methods = 0;
|
static int methods = 0;
|
||||||
static int ctors = 0;
|
static int ctors = 0;
|
||||||
static int props = 0;
|
static int props = 0;
|
||||||
static int sigs = 0;
|
static int sigs = 0;
|
||||||
static int throttled = 0;
|
static int throttled = 0;
|
||||||
static int ignored = 0;
|
static int ignored = 0;
|
||||||
static bool vm_ignored = false;
|
static bool vm_ignored = false;
|
||||||
|
|
||||||
public static int CBCount {
|
public static int CBCount {
|
||||||
get {
|
get {
|
||||||
return cbs;
|
return cbs;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
cbs = value;
|
cbs = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int EnumCount {
|
public static int EnumCount {
|
||||||
get {
|
get {
|
||||||
return enums;
|
return enums;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
enums = value;
|
enums = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ObjectCount {
|
public static int ObjectCount {
|
||||||
get {
|
get {
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
objects = value;
|
objects = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int StructCount {
|
public static int StructCount {
|
||||||
get {
|
get {
|
||||||
return structs;
|
return structs;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
structs = value;
|
structs = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int BoxedCount {
|
public static int BoxedCount {
|
||||||
get {
|
get {
|
||||||
return boxed;
|
return boxed;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
boxed = value;
|
boxed = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int OpaqueCount {
|
public static int OpaqueCount {
|
||||||
get {
|
get {
|
||||||
return opaques;
|
return opaques;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
opaques = value;
|
opaques = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int CtorCount {
|
public static int CtorCount {
|
||||||
get {
|
get {
|
||||||
return ctors;
|
return ctors;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
ctors = value;
|
ctors = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int MethodCount {
|
public static int MethodCount {
|
||||||
get {
|
get {
|
||||||
return methods;
|
return methods;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
methods = value;
|
methods = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int PropCount {
|
public static int PropCount {
|
||||||
get {
|
get {
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
props = value;
|
props = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int SignalCount {
|
public static int SignalCount {
|
||||||
get {
|
get {
|
||||||
return sigs;
|
return sigs;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
sigs = value;
|
sigs = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int IFaceCount {
|
public static int IFaceCount {
|
||||||
get {
|
get {
|
||||||
return interfaces;
|
return interfaces;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
interfaces = value;
|
interfaces = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ThrottledCount {
|
public static int ThrottledCount {
|
||||||
get {
|
get {
|
||||||
return throttled;
|
return throttled;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
throttled = value;
|
throttled = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int IgnoreCount {
|
public static int IgnoreCount {
|
||||||
get {
|
get {
|
||||||
return ignored;
|
return ignored;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
ignored = value;
|
ignored = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool VMIgnored {
|
public static bool VMIgnored {
|
||||||
get {
|
get {
|
||||||
return vm_ignored;
|
return vm_ignored;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if (value)
|
if (value)
|
||||||
vm_ignored = value;
|
vm_ignored = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Report()
|
public static void Report()
|
||||||
{
|
{
|
||||||
if (VMIgnored) {
|
if (VMIgnored) {
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("Warning: Generation throttled for Virtual Methods.");
|
Console.WriteLine("Warning: Generation throttled for Virtual Methods.");
|
||||||
Console.WriteLine(" Consider regenerating with --gluelib-name and --glue-filename.");
|
Console.WriteLine(" Consider regenerating with --gluelib-name and --glue-filename.");
|
||||||
}
|
}
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("Generation Summary:");
|
Console.WriteLine("Generation Summary:");
|
||||||
Console.Write(" Enums: " + enums);
|
Console.Write(" Enums: " + enums);
|
||||||
Console.Write(" Structs: " + structs);
|
Console.Write(" Structs: " + structs);
|
||||||
Console.Write(" Boxed: " + boxed);
|
Console.Write(" Boxed: " + boxed);
|
||||||
Console.Write(" Opaques: " + opaques);
|
Console.Write(" Opaques: " + opaques);
|
||||||
Console.Write(" Interfaces: " + interfaces);
|
Console.Write(" Interfaces: " + interfaces);
|
||||||
Console.Write(" Objects: " + objects);
|
Console.Write(" Objects: " + objects);
|
||||||
Console.WriteLine(" Callbacks: " + cbs);
|
Console.WriteLine(" Callbacks: " + cbs);
|
||||||
Console.Write(" Properties: " + props);
|
Console.Write(" Properties: " + props);
|
||||||
Console.Write(" Signals: " + sigs);
|
Console.Write(" Signals: " + sigs);
|
||||||
Console.Write(" Methods: " + methods);
|
Console.Write(" Methods: " + methods);
|
||||||
Console.Write(" Constructors: " + ctors);
|
Console.Write(" Constructors: " + ctors);
|
||||||
Console.WriteLine(" Throttled: " + throttled);
|
Console.WriteLine(" Throttled: " + throttled);
|
||||||
Console.WriteLine("Total Nodes: " + (enums+structs+boxed+opaques+interfaces+cbs+objects+props+sigs+methods+ctors+throttled));
|
Console.WriteLine("Total Nodes: " + (enums+structs+boxed+opaques+interfaces+cbs+objects+props+sigs+methods+ctors+throttled));
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
// GtkSharp.Generation.StructGen.cs - The Structure Generatable.
|
// GtkSharp.Generation.StructGen.cs - The Structure Generatable.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001 Mike Kestner
|
// Copyright (c) 2001 Mike Kestner
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class StructGen : StructBase {
|
public class StructGen : StructBase {
|
||||||
|
|
||||||
public StructGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
public StructGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
||||||
|
|
||||||
public override void Generate (GenerationInfo gen_info)
|
public override void Generate (GenerationInfo gen_info)
|
||||||
{
|
{
|
||||||
gen_info.CurrentType = QualifiedName;
|
gen_info.CurrentType = QualifiedName;
|
||||||
|
|
||||||
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
||||||
base.Generate (gen_info);
|
base.Generate (gen_info);
|
||||||
if (GetMethod ("GetType") == null && GetMethod ("GetGType") == null) {
|
if (GetMethod ("GetType") == null && GetMethod ("GetGType") == null) {
|
||||||
sw.WriteLine ("\t\tprivate static GLib.GType GType {");
|
sw.WriteLine ("\t\tprivate static GLib.GType GType {");
|
||||||
sw.WriteLine ("\t\t\tget { return GLib.GType.Pointer; }");
|
sw.WriteLine ("\t\t\tget { return GLib.GType.Pointer; }");
|
||||||
sw.WriteLine ("\t\t}");
|
sw.WriteLine ("\t\t}");
|
||||||
}
|
}
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
gen_info.Writer = null;
|
gen_info.Writer = null;
|
||||||
Statistics.StructCount++;
|
Statistics.StructCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,388 +1,388 @@
|
|||||||
// GtkSharp.Generation.SymbolTable.cs - The Symbol Table Class.
|
// GtkSharp.Generation.SymbolTable.cs - The Symbol Table Class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001-2003 Mike Kestner
|
// Copyright (c) 2001-2003 Mike Kestner
|
||||||
// Copyright (c) 2004-2005 Novell, Inc.
|
// Copyright (c) 2004-2005 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
public class SymbolTable {
|
public class SymbolTable {
|
||||||
|
|
||||||
static SymbolTable table = null;
|
static SymbolTable table = null;
|
||||||
|
|
||||||
Hashtable types = new Hashtable ();
|
Hashtable types = new Hashtable ();
|
||||||
|
|
||||||
public static SymbolTable Table {
|
public static SymbolTable Table {
|
||||||
get {
|
get {
|
||||||
if (table == null)
|
if (table == null)
|
||||||
table = new SymbolTable ();
|
table = new SymbolTable ();
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SymbolTable ()
|
public SymbolTable ()
|
||||||
{
|
{
|
||||||
// Simple easily mapped types
|
// Simple easily mapped types
|
||||||
AddType (new SimpleGen ("void", "void", String.Empty));
|
AddType (new SimpleGen ("void", "void", String.Empty));
|
||||||
AddType (new SimpleGen ("gpointer", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("gpointer", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("AtkFunction", "IntPtr", "IntPtr.Zero")); // function definition used for padding
|
AddType (new SimpleGen ("AtkFunction", "IntPtr", "IntPtr.Zero")); // function definition used for padding
|
||||||
AddType (new SimpleGen ("gboolean", "bool", "false"));
|
AddType (new SimpleGen ("gboolean", "bool", "false"));
|
||||||
AddType (new SimpleGen ("gint", "int", "0"));
|
AddType (new SimpleGen ("gint", "int", "0"));
|
||||||
AddType (new SimpleGen ("guint", "uint", "0"));
|
AddType (new SimpleGen ("guint", "uint", "0"));
|
||||||
AddType (new SimpleGen ("int", "int", "0"));
|
AddType (new SimpleGen ("int", "int", "0"));
|
||||||
AddType (new SimpleGen ("unsigned", "uint", "0"));
|
AddType (new SimpleGen ("unsigned", "uint", "0"));
|
||||||
AddType (new SimpleGen ("unsigned int", "uint", "0"));
|
AddType (new SimpleGen ("unsigned int", "uint", "0"));
|
||||||
AddType (new SimpleGen ("unsigned-int", "uint", "0"));
|
AddType (new SimpleGen ("unsigned-int", "uint", "0"));
|
||||||
AddType (new SimpleGen ("gshort", "short", "0"));
|
AddType (new SimpleGen ("gshort", "short", "0"));
|
||||||
AddType (new SimpleGen ("gushort", "ushort", "0"));
|
AddType (new SimpleGen ("gushort", "ushort", "0"));
|
||||||
AddType (new SimpleGen ("short", "short", "0"));
|
AddType (new SimpleGen ("short", "short", "0"));
|
||||||
AddType (new SimpleGen ("guchar", "byte", "0"));
|
AddType (new SimpleGen ("guchar", "byte", "0"));
|
||||||
AddType (new SimpleGen ("unsigned char", "byte", "0"));
|
AddType (new SimpleGen ("unsigned char", "byte", "0"));
|
||||||
AddType (new SimpleGen ("unsigned-char", "byte", "0"));
|
AddType (new SimpleGen ("unsigned-char", "byte", "0"));
|
||||||
AddType (new SimpleGen ("guint1", "bool", "false"));
|
AddType (new SimpleGen ("guint1", "bool", "false"));
|
||||||
AddType (new SimpleGen ("uint1", "bool", "false"));
|
AddType (new SimpleGen ("uint1", "bool", "false"));
|
||||||
AddType (new SimpleGen ("gint8", "sbyte", "0"));
|
AddType (new SimpleGen ("gint8", "sbyte", "0"));
|
||||||
AddType (new SimpleGen ("guint8", "byte", "0"));
|
AddType (new SimpleGen ("guint8", "byte", "0"));
|
||||||
AddType (new SimpleGen ("gint16", "short", "0"));
|
AddType (new SimpleGen ("gint16", "short", "0"));
|
||||||
AddType (new SimpleGen ("guint16", "ushort", "0"));
|
AddType (new SimpleGen ("guint16", "ushort", "0"));
|
||||||
AddType (new SimpleGen ("gint32", "int", "0"));
|
AddType (new SimpleGen ("gint32", "int", "0"));
|
||||||
AddType (new SimpleGen ("guint32", "uint", "0"));
|
AddType (new SimpleGen ("guint32", "uint", "0"));
|
||||||
AddType (new SimpleGen ("gint64", "long", "0"));
|
AddType (new SimpleGen ("gint64", "long", "0"));
|
||||||
AddType (new SimpleGen ("guint64", "ulong", "0"));
|
AddType (new SimpleGen ("guint64", "ulong", "0"));
|
||||||
AddType (new SimpleGen ("long long", "long", "0"));
|
AddType (new SimpleGen ("long long", "long", "0"));
|
||||||
AddType (new SimpleGen ("gfloat", "float", "0.0"));
|
AddType (new SimpleGen ("gfloat", "float", "0.0"));
|
||||||
AddType (new SimpleGen ("float", "float", "0.0"));
|
AddType (new SimpleGen ("float", "float", "0.0"));
|
||||||
AddType (new SimpleGen ("gdouble", "double", "0.0"));
|
AddType (new SimpleGen ("gdouble", "double", "0.0"));
|
||||||
AddType (new SimpleGen ("double", "double", "0.0"));
|
AddType (new SimpleGen ("double", "double", "0.0"));
|
||||||
AddType (new SimpleGen ("goffset", "long", "0"));
|
AddType (new SimpleGen ("goffset", "long", "0"));
|
||||||
AddType (new SimpleGen ("GQuark", "int", "0"));
|
AddType (new SimpleGen ("GQuark", "int", "0"));
|
||||||
|
|
||||||
// platform specific integer types.
|
// platform specific integer types.
|
||||||
#if WIN64LONGS
|
#if WIN64LONGS
|
||||||
AddType (new SimpleGen ("long", "int", "0"));
|
AddType (new SimpleGen ("long", "int", "0"));
|
||||||
AddType (new SimpleGen ("glong", "int", "0"));
|
AddType (new SimpleGen ("glong", "int", "0"));
|
||||||
AddType (new SimpleGen ("ulong", "uint", "0"));
|
AddType (new SimpleGen ("ulong", "uint", "0"));
|
||||||
AddType (new SimpleGen ("gulong", "uint", "0"));
|
AddType (new SimpleGen ("gulong", "uint", "0"));
|
||||||
AddType (new SimpleGen ("unsigned long", "uint", "0"));
|
AddType (new SimpleGen ("unsigned long", "uint", "0"));
|
||||||
AddType (new SimpleGen ("gintptr", "int", "0"));
|
AddType (new SimpleGen ("gintptr", "int", "0"));
|
||||||
AddType (new SimpleGen ("guintptr", "uint", "0"));
|
AddType (new SimpleGen ("guintptr", "uint", "0"));
|
||||||
#else
|
#else
|
||||||
AddType (new LPGen ("long"));
|
AddType (new LPGen ("long"));
|
||||||
AddType (new LPGen ("glong"));
|
AddType (new LPGen ("glong"));
|
||||||
AddType (new LPGen ("gintptr"));
|
AddType (new LPGen ("gintptr"));
|
||||||
AddType (new LPUGen ("ulong"));
|
AddType (new LPUGen ("ulong"));
|
||||||
AddType (new LPUGen ("gulong"));
|
AddType (new LPUGen ("gulong"));
|
||||||
AddType (new LPUGen ("unsigned long"));
|
AddType (new LPUGen ("unsigned long"));
|
||||||
AddType (new LPUGen ("guintptr"));
|
AddType (new LPUGen ("guintptr"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AddType (new LPGen ("ssize_t"));
|
AddType (new LPGen ("ssize_t"));
|
||||||
AddType (new LPGen ("gssize"));
|
AddType (new LPGen ("gssize"));
|
||||||
AddType (new LPUGen ("size_t"));
|
AddType (new LPUGen ("size_t"));
|
||||||
AddType (new LPUGen ("gsize"));
|
AddType (new LPUGen ("gsize"));
|
||||||
|
|
||||||
#if OFF_T_8
|
#if OFF_T_8
|
||||||
AddType (new AliasGen ("off_t", "long"));
|
AddType (new AliasGen ("off_t", "long"));
|
||||||
#else
|
#else
|
||||||
AddType (new LPGen ("off_t"));
|
AddType (new LPGen ("off_t"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// string types
|
// string types
|
||||||
AddType (new ConstStringGen ("const-gchar"));
|
AddType (new ConstStringGen ("const-gchar"));
|
||||||
AddType (new ConstStringGen ("const-xmlChar"));
|
AddType (new ConstStringGen ("const-xmlChar"));
|
||||||
AddType (new ConstStringGen ("const-char"));
|
AddType (new ConstStringGen ("const-char"));
|
||||||
AddType (new ConstFilenameGen ("const-gfilename"));
|
AddType (new ConstFilenameGen ("const-gfilename"));
|
||||||
AddType (new MarshalGen ("gfilename", "string", "IntPtr", "GLib.Marshaller.StringToFilenamePtr({0})", "GLib.Marshaller.FilenamePtrToStringGFree({0})"));
|
AddType (new MarshalGen ("gfilename", "string", "IntPtr", "GLib.Marshaller.StringToFilenamePtr({0})", "GLib.Marshaller.FilenamePtrToStringGFree({0})"));
|
||||||
AddType (new MarshalGen ("gchar", "string", "IntPtr", "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})"));
|
AddType (new MarshalGen ("gchar", "string", "IntPtr", "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})"));
|
||||||
AddType (new MarshalGen ("char", "string", "IntPtr", "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})"));
|
AddType (new MarshalGen ("char", "string", "IntPtr", "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})"));
|
||||||
AddType (new SimpleGen ("GStrv", "string[]", "null"));
|
AddType (new SimpleGen ("GStrv", "string[]", "null"));
|
||||||
|
|
||||||
// manually wrapped types requiring more complex marshaling
|
// manually wrapped types requiring more complex marshaling
|
||||||
AddType (new ManualGen ("GInitiallyUnowned", "GLib.InitiallyUnowned", "GLib.Object.GetObject ({0})"));
|
AddType (new ManualGen ("GInitiallyUnowned", "GLib.InitiallyUnowned", "GLib.Object.GetObject ({0})"));
|
||||||
AddType (new ManualGen ("GObject", "GLib.Object", "GLib.Object.GetObject ({0})"));
|
AddType (new ManualGen ("GObject", "GLib.Object", "GLib.Object.GetObject ({0})"));
|
||||||
AddType (new ManualGen ("GList", "GLib.List"));
|
AddType (new ManualGen ("GList", "GLib.List"));
|
||||||
AddType (new ManualGen ("GPtrArray", "GLib.PtrArray"));
|
AddType (new ManualGen ("GPtrArray", "GLib.PtrArray"));
|
||||||
AddType (new ManualGen ("GSList", "GLib.SList"));
|
AddType (new ManualGen ("GSList", "GLib.SList"));
|
||||||
AddType (new ManualGen ("GVariant", "GLib.Variant"));
|
AddType (new ManualGen ("GVariant", "GLib.Variant"));
|
||||||
AddType (new ManualGen ("GVariantType", "GLib.VariantType"));
|
AddType (new ManualGen ("GVariantType", "GLib.VariantType"));
|
||||||
AddType (new ManualGen ("GValueArray", "GLib.ValueArray"));
|
AddType (new ManualGen ("GValueArray", "GLib.ValueArray"));
|
||||||
AddType (new MarshalGen ("gunichar", "char", "uint", "GLib.Marshaller.CharToGUnichar ({0})", "GLib.Marshaller.GUnicharToChar ({0})"));
|
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 ("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 ("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 MarshalGen ("GType", "GLib.GType", "IntPtr", "{0}.Val", "new GLib.GType({0})", "GLib.GType.None"));
|
||||||
AddType (new ByRefGen ("GValue", "GLib.Value"));
|
AddType (new ByRefGen ("GValue", "GLib.Value"));
|
||||||
AddType (new SimpleGen ("GDestroyNotify", "GLib.DestroyNotify", "null"));
|
AddType (new SimpleGen ("GDestroyNotify", "GLib.DestroyNotify", "null"));
|
||||||
|
|
||||||
// FIXME: These ought to be handled properly.
|
// FIXME: These ought to be handled properly.
|
||||||
AddType (new SimpleGen ("GC", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GC", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GError", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GError", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GMemChunk", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GMemChunk", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GTimeVal", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GTimeVal", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GClosure", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GClosure", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GArray", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GArray", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GByteArray", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GByteArray", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GData", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GData", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GIOChannel", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GIOChannel", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GTypeModule", "GLib.Object", "null"));
|
AddType (new SimpleGen ("GTypeModule", "GLib.Object", "null"));
|
||||||
AddType (new SimpleGen ("GHashTable", "System.IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GHashTable", "System.IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("va_list", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("va_list", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("GParamSpec", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("GParamSpec", "IntPtr", "IntPtr.Zero"));
|
||||||
AddType (new SimpleGen ("gconstpointer", "IntPtr", "IntPtr.Zero"));
|
AddType (new SimpleGen ("gconstpointer", "IntPtr", "IntPtr.Zero"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddType (IGeneratable gen)
|
public void AddType (IGeneratable gen)
|
||||||
{
|
{
|
||||||
types [gen.CName] = gen;
|
types [gen.CName] = gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTypes (IGeneratable[] gens)
|
public void AddTypes (IGeneratable[] gens)
|
||||||
{
|
{
|
||||||
foreach (IGeneratable gen in gens)
|
foreach (IGeneratable gen in gens)
|
||||||
types [gen.CName] = gen;
|
types [gen.CName] = gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count {
|
public int Count {
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return types.Count;
|
return types.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable Generatables {
|
public IEnumerable Generatables {
|
||||||
get {
|
get {
|
||||||
return types.Values;
|
return types.Values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IGeneratable this [string ctype] {
|
public IGeneratable this [string ctype] {
|
||||||
get {
|
get {
|
||||||
return DeAlias (ctype) as IGeneratable;
|
return DeAlias (ctype) as IGeneratable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsConstString (string type)
|
private bool IsConstString (string type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "const-gchar":
|
case "const-gchar":
|
||||||
case "const-char":
|
case "const-char":
|
||||||
case "const-xmlChar":
|
case "const-xmlChar":
|
||||||
case "const-gfilename":
|
case "const-gfilename":
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string Trim(string type)
|
private string Trim(string type)
|
||||||
{
|
{
|
||||||
// HACK: If we don't detect this here, there is no
|
// HACK: If we don't detect this here, there is no
|
||||||
// way of indicating it in the symbol table
|
// way of indicating it in the symbol table
|
||||||
if (type == "void*" || type == "const-void*") return "gpointer";
|
if (type == "void*" || type == "const-void*") return "gpointer";
|
||||||
|
|
||||||
string trim_type = type.TrimEnd('*');
|
string trim_type = type.TrimEnd('*');
|
||||||
|
|
||||||
if (IsConstString (trim_type))
|
if (IsConstString (trim_type))
|
||||||
return trim_type;
|
return trim_type;
|
||||||
|
|
||||||
if (trim_type.StartsWith("const-")) return trim_type.Substring(6);
|
if (trim_type.StartsWith("const-")) return trim_type.Substring(6);
|
||||||
return trim_type;
|
return trim_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private object DeAlias (string type)
|
private object DeAlias (string type)
|
||||||
{
|
{
|
||||||
type = Trim (type);
|
type = Trim (type);
|
||||||
while (types [type] is AliasGen) {
|
while (types [type] is AliasGen) {
|
||||||
IGeneratable igen = types [type] as AliasGen;
|
IGeneratable igen = types [type] as AliasGen;
|
||||||
types [type] = types [igen.Name];
|
types [type] = types [igen.Name];
|
||||||
type = igen.Name;
|
type = igen.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return types [type];
|
return types [type];
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FromNative(string c_type, string val)
|
public string FromNative(string c_type, string val)
|
||||||
{
|
{
|
||||||
IGeneratable gen = this[c_type];
|
IGeneratable gen = this[c_type];
|
||||||
if (gen == null)
|
if (gen == null)
|
||||||
return "";
|
return "";
|
||||||
return gen.FromNative (val);
|
return gen.FromNative (val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCSType(string c_type)
|
public string GetCSType(string c_type)
|
||||||
{
|
{
|
||||||
IGeneratable gen = this[c_type];
|
IGeneratable gen = this[c_type];
|
||||||
if (gen == null)
|
if (gen == null)
|
||||||
return "";
|
return "";
|
||||||
return gen.QualifiedName;
|
return gen.QualifiedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName(string c_type)
|
public string GetName(string c_type)
|
||||||
{
|
{
|
||||||
IGeneratable gen = this[c_type];
|
IGeneratable gen = this[c_type];
|
||||||
if (gen == null)
|
if (gen == null)
|
||||||
return "";
|
return "";
|
||||||
return gen.Name;
|
return gen.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetMarshalType(string c_type)
|
public string GetMarshalType(string c_type)
|
||||||
{
|
{
|
||||||
IGeneratable gen = this[c_type];
|
IGeneratable gen = this[c_type];
|
||||||
if (gen == null)
|
if (gen == null)
|
||||||
return "";
|
return "";
|
||||||
return gen.MarshalType;
|
return gen.MarshalType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CallByName(string c_type, string var_name)
|
public string CallByName(string c_type, string var_name)
|
||||||
{
|
{
|
||||||
IGeneratable gen = this[c_type];
|
IGeneratable gen = this[c_type];
|
||||||
if (gen == null)
|
if (gen == null)
|
||||||
return "";
|
return "";
|
||||||
return gen.CallByName(var_name);
|
return gen.CallByName(var_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsOpaque(string c_type)
|
public bool IsOpaque(string c_type)
|
||||||
{
|
{
|
||||||
if (this[c_type] is OpaqueGen)
|
if (this[c_type] is OpaqueGen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsBoxed(string c_type)
|
public bool IsBoxed(string c_type)
|
||||||
{
|
{
|
||||||
if (this[c_type] is BoxedGen)
|
if (this[c_type] is BoxedGen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsStruct(string c_type)
|
public bool IsStruct(string c_type)
|
||||||
{
|
{
|
||||||
if (this[c_type] is StructGen)
|
if (this[c_type] is StructGen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEnum(string c_type)
|
public bool IsEnum(string c_type)
|
||||||
{
|
{
|
||||||
if (this[c_type] is EnumGen)
|
if (this[c_type] is EnumGen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEnumFlags(string c_type)
|
public bool IsEnumFlags(string c_type)
|
||||||
{
|
{
|
||||||
EnumGen gen = this [c_type] as EnumGen;
|
EnumGen gen = this [c_type] as EnumGen;
|
||||||
return (gen != null && gen.Elem.GetAttribute ("type") == "flags");
|
return (gen != null && gen.Elem.GetAttribute ("type") == "flags");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInterface(string c_type)
|
public bool IsInterface(string c_type)
|
||||||
{
|
{
|
||||||
if (this[c_type] is InterfaceGen)
|
if (this[c_type] is InterfaceGen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassBase GetClassGen(string c_type)
|
public ClassBase GetClassGen(string c_type)
|
||||||
{
|
{
|
||||||
return this[c_type] as ClassBase;
|
return this[c_type] as ClassBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsObject(string c_type)
|
public bool IsObject(string c_type)
|
||||||
{
|
{
|
||||||
if (this[c_type] is ObjectGen)
|
if (this[c_type] is ObjectGen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsCallback(string c_type)
|
public bool IsCallback(string c_type)
|
||||||
{
|
{
|
||||||
if (this[c_type] is CallbackGen)
|
if (this[c_type] is CallbackGen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsManuallyWrapped(string c_type)
|
public bool IsManuallyWrapped(string c_type)
|
||||||
{
|
{
|
||||||
if (this[c_type] is ManualGen)
|
if (this[c_type] is ManualGen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string MangleName(string name)
|
public string MangleName(string name)
|
||||||
{
|
{
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "string":
|
case "string":
|
||||||
return "str1ng";
|
return "str1ng";
|
||||||
case "event":
|
case "event":
|
||||||
return "evnt";
|
return "evnt";
|
||||||
case "null":
|
case "null":
|
||||||
return "is_null";
|
return "is_null";
|
||||||
case "object":
|
case "object":
|
||||||
return "objekt";
|
return "objekt";
|
||||||
case "params":
|
case "params":
|
||||||
return "parms";
|
return "parms";
|
||||||
case "ref":
|
case "ref":
|
||||||
return "reference";
|
return "reference";
|
||||||
case "in":
|
case "in":
|
||||||
return "in_param";
|
return "in_param";
|
||||||
case "out":
|
case "out":
|
||||||
return "out_param";
|
return "out_param";
|
||||||
case "fixed":
|
case "fixed":
|
||||||
return "mfixed";
|
return "mfixed";
|
||||||
case "byte":
|
case "byte":
|
||||||
return "_byte";
|
return "_byte";
|
||||||
case "new":
|
case "new":
|
||||||
return "_new";
|
return "_new";
|
||||||
case "base":
|
case "base":
|
||||||
return "_base";
|
return "_base";
|
||||||
case "lock":
|
case "lock":
|
||||||
return "_lock";
|
return "_lock";
|
||||||
case "callback":
|
case "callback":
|
||||||
return "cb";
|
return "cb";
|
||||||
case "readonly":
|
case "readonly":
|
||||||
return "read_only";
|
return "read_only";
|
||||||
case "interface":
|
case "interface":
|
||||||
return "iface";
|
return "iface";
|
||||||
case "internal":
|
case "internal":
|
||||||
return "_internal";
|
return "_internal";
|
||||||
case "where":
|
case "where":
|
||||||
return "wh3r3";
|
return "wh3r3";
|
||||||
case "foreach":
|
case "foreach":
|
||||||
return "for_each";
|
return "for_each";
|
||||||
case "remove":
|
case "remove":
|
||||||
return "_remove";
|
return "_remove";
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,91 +1,91 @@
|
|||||||
// GtkSharp.Generation.VMSignature.cs - The Virtual Method Signature Generation Class.
|
// GtkSharp.Generation.VMSignature.cs - The Virtual Method Signature Generation Class.
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@ximian.com>
|
// Author: Mike Kestner <mkestner@ximian.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2003-2004 Novell, Inc.
|
// Copyright (c) 2003-2004 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the GNU General Public
|
// modify it under the terms of version 2 of the GNU General Public
|
||||||
// License as published by the Free Software Foundation.
|
// License as published by the Free Software Foundation.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public
|
// You should have received a copy of the GNU General Public
|
||||||
// License along with this program; if not, write to the
|
// License along with this program; if not, write to the
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class VMSignature {
|
public class VMSignature {
|
||||||
|
|
||||||
private ArrayList parms = new ArrayList ();
|
private ArrayList parms = new ArrayList ();
|
||||||
|
|
||||||
public VMSignature (Parameters parms)
|
public VMSignature (Parameters parms)
|
||||||
{
|
{
|
||||||
bool has_cb = parms.HideData;
|
bool has_cb = parms.HideData;
|
||||||
for (int i = 0; i < parms.Count; i++) {
|
for (int i = 0; i < parms.Count; i++) {
|
||||||
Parameter p = parms [i];
|
Parameter p = parms [i];
|
||||||
|
|
||||||
if (i > 0 && p.IsLength && parms [i - 1].IsString)
|
if (i > 0 && p.IsLength && parms [i - 1].IsString)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (p.IsCount && ((i > 0 && parms [i - 1].IsArray) || (i < parms.Count - 1 && parms [i + 1].IsArray)))
|
if (p.IsCount && ((i > 0 && parms [i - 1].IsArray) || (i < parms.Count - 1 && parms [i + 1].IsArray)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
has_cb = has_cb || p.Generatable is CallbackGen;
|
has_cb = has_cb || p.Generatable is CallbackGen;
|
||||||
if (p.IsUserData && has_cb)
|
if (p.IsUserData && has_cb)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (p.CType == "GError**")
|
if (p.CType == "GError**")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (p.Scope == "notified")
|
if (p.Scope == "notified")
|
||||||
i += 2;
|
i += 2;
|
||||||
|
|
||||||
this.parms.Add (p);
|
this.parms.Add (p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCallString (bool use_place_holders)
|
public string GetCallString (bool use_place_holders)
|
||||||
{
|
{
|
||||||
if (parms.Count == 0)
|
if (parms.Count == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
string[] result = new string [parms.Count];
|
string[] result = new string [parms.Count];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (Parameter p in parms) {
|
foreach (Parameter p in parms) {
|
||||||
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
||||||
result [i] += use_place_holders ? "{" + i + "}" : p.Name;
|
result [i] += use_place_holders ? "{" + i + "}" : p.Name;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.Join (", ", result);
|
return String.Join (", ", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString ()
|
public override string ToString ()
|
||||||
{
|
{
|
||||||
if (parms.Count == 0)
|
if (parms.Count == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
string[] result = new string [parms.Count];
|
string[] result = new string [parms.Count];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
foreach (Parameter p in parms) {
|
foreach (Parameter p in parms) {
|
||||||
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
|
||||||
result [i++] += p.CSType + " " + p.Name;
|
result [i++] += p.CSType + " " + p.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.Join (", ", result);
|
return String.Join (", ", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user