mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-07 07:23:18 +02:00
generator: Switch a lot of collections to their generic counterpart
The additional type information makes the code a bit more safe and readable. At least one bug is fixed by this: in ObjectGen, an invalid child property could still be generated, as it was not removed from the hash table. This should cause no real change to the generated code, except maybe in the order of some members.
This commit is contained in:
parent
608a760d45
commit
82a957bc9d
@ -23,7 +23,7 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class ArrayParameter : Parameter {
|
public class ArrayParameter : Parameter {
|
||||||
@ -55,7 +55,7 @@ namespace GtkSharp.Generation {
|
|||||||
if (CSType == MarshalType)
|
if (CSType == MarshalType)
|
||||||
return new string [0];
|
return new string [0];
|
||||||
|
|
||||||
ArrayList result = new ArrayList ();
|
var result = new List<string> ();
|
||||||
result.Add (String.Format ("int cnt_{0} = {0} == null ? 0 : {0}.Length;", CallName));
|
result.Add (String.Format ("int cnt_{0} = {0} == null ? 0 : {0}.Length;", CallName));
|
||||||
result.Add (String.Format ("{0}[] native_{1} = new {0} [cnt_{1}" + (NullTerminated ? " + 1" : "") + "];", MarshalType.TrimEnd('[', ']'), CallName));
|
result.Add (String.Format ("{0}[] native_{1} = new {0} [cnt_{1}" + (NullTerminated ? " + 1" : "") + "];", MarshalType.TrimEnd('[', ']'), CallName));
|
||||||
result.Add (String.Format ("for (int i = 0; i < cnt_{0}; i++)", CallName));
|
result.Add (String.Format ("for (int i = 0; i < cnt_{0}; i++)", CallName));
|
||||||
@ -67,7 +67,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
if (NullTerminated)
|
if (NullTerminated)
|
||||||
result.Add (String.Format ("native_{0} [cnt_{0}] = IntPtr.Zero;", CallName));
|
result.Add (String.Format ("native_{0} [cnt_{0}] = IntPtr.Zero;", CallName));
|
||||||
return (string[]) result.ToArray (typeof (string));
|
return result.ToArray ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
@ -33,12 +34,12 @@ namespace GtkSharp.Generation {
|
|||||||
protected Hashtable props = new Hashtable();
|
protected Hashtable props = new Hashtable();
|
||||||
protected Hashtable fields = new Hashtable();
|
protected Hashtable fields = new Hashtable();
|
||||||
protected Hashtable methods = new Hashtable();
|
protected Hashtable methods = new Hashtable();
|
||||||
protected ArrayList interfaces = new ArrayList();
|
protected IList<string> interfaces = new List<string>();
|
||||||
protected ArrayList managed_interfaces = new ArrayList();
|
protected IList<string> managed_interfaces = new List<string>();
|
||||||
protected ArrayList ctors = new ArrayList();
|
protected IList<Ctor> ctors = new List<Ctor>();
|
||||||
|
|
||||||
private bool ctors_initted = false;
|
private bool ctors_initted = false;
|
||||||
private Hashtable clash_map;
|
private Dictionary<string, Ctor> clash_map;
|
||||||
private bool deprecated = false;
|
private bool deprecated = false;
|
||||||
private bool isabstract = false;
|
private bool isabstract = false;
|
||||||
|
|
||||||
@ -240,8 +241,8 @@ namespace GtkSharp.Generation {
|
|||||||
(fields != null) && fields.ContainsKey(mname.Substring(3))));
|
(fields != null) && fields.ContainsKey(mname.Substring(3))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenMethods (GenerationInfo gen_info, Hashtable collisions, ClassBase implementor)
|
public void GenMethods (GenerationInfo gen_info, IDictionary<string, bool> collisions, ClassBase implementor)
|
||||||
{
|
{
|
||||||
if (methods == null)
|
if (methods == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -250,7 +251,7 @@ namespace GtkSharp.Generation {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
string oname = null, oprotection = null;
|
string oname = null, oprotection = null;
|
||||||
if (collisions != null && collisions.Contains (method.Name)) {
|
if (collisions != null && collisions.ContainsKey (method.Name)) {
|
||||||
oname = method.Name;
|
oname = method.Name;
|
||||||
oprotection = method.Protection;
|
oprotection = method.Protection;
|
||||||
method.Name = QualifiedName + "." + method.Name;
|
method.Name = QualifiedName + "." + method.Name;
|
||||||
@ -332,7 +333,7 @@ namespace GtkSharp.Generation {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList Ctors { get { return ctors; } }
|
public IList<Ctor> Ctors { get { return ctors; } }
|
||||||
|
|
||||||
bool HasStaticCtor (string name)
|
bool HasStaticCtor (string name)
|
||||||
{
|
{
|
||||||
@ -354,12 +355,12 @@ namespace GtkSharp.Generation {
|
|||||||
if (Parent != null)
|
if (Parent != null)
|
||||||
Parent.InitializeCtors ();
|
Parent.InitializeCtors ();
|
||||||
|
|
||||||
ArrayList valid_ctors = new ArrayList();
|
var valid_ctors = new List<Ctor>();
|
||||||
clash_map = new Hashtable();
|
clash_map = new Dictionary<string, Ctor>();
|
||||||
|
|
||||||
foreach (Ctor ctor in ctors) {
|
foreach (Ctor ctor in ctors) {
|
||||||
if (clash_map.Contains (ctor.Signature.Types)) {
|
if (clash_map.ContainsKey (ctor.Signature.Types)) {
|
||||||
Ctor clash = clash_map [ctor.Signature.Types] as Ctor;
|
Ctor clash = clash_map [ctor.Signature.Types];
|
||||||
Ctor alter = ctor.Preferred ? clash : ctor;
|
Ctor alter = ctor.Preferred ? clash : ctor;
|
||||||
alter.IsStatic = true;
|
alter.IsStatic = true;
|
||||||
if (Parent != null && Parent.HasStaticCtor (alter.StaticName))
|
if (Parent != null && Parent.HasStaticCtor (alter.StaticName))
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class CodeGenerator {
|
public class CodeGenerator {
|
||||||
@ -43,7 +43,7 @@ namespace GtkSharp.Generation {
|
|||||||
string gluelib_name = "";
|
string gluelib_name = "";
|
||||||
|
|
||||||
SymbolTable table = SymbolTable.Table;
|
SymbolTable table = SymbolTable.Table;
|
||||||
ArrayList gens = new ArrayList ();
|
var gens = new List<IGeneratable> ();
|
||||||
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.");
|
||||||
@ -90,7 +90,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
// 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 ();
|
var invalids = new List<IGeneratable> ();
|
||||||
foreach (IGeneratable gen in gens) {
|
foreach (IGeneratable gen in gens) {
|
||||||
if (!gen.Validate ())
|
if (!gen.Validate ())
|
||||||
invalids.Add (gen);
|
invalids.Add (gen);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
@ -109,8 +109,8 @@ namespace GtkSharp.Generation {
|
|||||||
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 ();
|
var names = new List<string> ();
|
||||||
ArrayList values = new ArrayList ();
|
var values = new List<string> ();
|
||||||
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) {
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -30,7 +30,7 @@ namespace GtkSharp.Generation {
|
|||||||
public class EnumGen : GenBase {
|
public class EnumGen : GenBase {
|
||||||
|
|
||||||
string enum_type = String.Empty;
|
string enum_type = String.Empty;
|
||||||
ArrayList members = new ArrayList ();
|
IList<string> members = new List<string> ();
|
||||||
|
|
||||||
public EnumGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
public EnumGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace GtkSharp.Generation {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
LogWriter log = new LogWriter (QualifiedName);
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
ArrayList invalids = new ArrayList ();
|
var invalids = new List<Method> ();
|
||||||
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);
|
||||||
@ -264,7 +264,7 @@ namespace GtkSharp.Generation {
|
|||||||
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, null, this);
|
||||||
if (temp != null)
|
if (temp != null)
|
||||||
methods ["GetType"] = temp;
|
methods ["GetType"] = temp;
|
||||||
|
|
||||||
@ -287,20 +287,20 @@ namespace GtkSharp.Generation {
|
|||||||
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 ();
|
var vm_table = new Dictionary<string, InterfaceVM> ();
|
||||||
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.ContainsKey (vm.Name)) {
|
||||||
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 = null;
|
||||||
if (cmp != null && (cmp.IsGetter || cmp.IsSetter)) {
|
if (vm_table.TryGetValue (cmp_name, out cmp) && (cmp.IsGetter || cmp.IsSetter)) {
|
||||||
if (vm.IsSetter)
|
if (vm.IsSetter)
|
||||||
cmp.GenerateDeclaration (sw, vm);
|
cmp.GenerateDeclaration (sw, vm);
|
||||||
else
|
else
|
||||||
|
@ -24,6 +24,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
@ -32,12 +33,12 @@ namespace GtkSharp.Generation {
|
|||||||
protected string class_struct_name = null;
|
protected string class_struct_name = null;
|
||||||
bool class_fields_valid; // false if the class structure contains a bitfield or fields of unknown types
|
bool class_fields_valid; // false if the class structure contains a bitfield or fields of unknown types
|
||||||
ArrayList class_members = new ArrayList ();
|
ArrayList class_members = new ArrayList ();
|
||||||
protected ArrayList class_fields = new ArrayList ();
|
protected IList<ClassField> class_fields = new List<ClassField> ();
|
||||||
// The default handlers of these signals need to be overridden with g_signal_override_class_closure
|
// The default handlers of these signals need to be overridden with g_signal_override_class_closure
|
||||||
protected ArrayList virtual_methods = new ArrayList ();
|
protected IList<GObjectVM> virtual_methods = new List<GObjectVM> ();
|
||||||
// virtual methods that are generated as an IntPtr in the class struct
|
// virtual methods that are generated as an IntPtr in the class struct
|
||||||
protected ArrayList hidden_vms = new ArrayList ();
|
protected IList<VirtualMethod> hidden_vms = new List<VirtualMethod> ();
|
||||||
protected ArrayList interface_vms = new ArrayList ();
|
protected IList<InterfaceVM> interface_vms = new List<InterfaceVM> ();
|
||||||
protected Hashtable sigs = new Hashtable();
|
protected Hashtable sigs = new Hashtable();
|
||||||
|
|
||||||
protected ObjectBase (XmlElement ns, XmlElement elem, bool is_interface) : base (ns, elem)
|
protected ObjectBase (XmlElement ns, XmlElement elem, bool is_interface) : base (ns, elem)
|
||||||
@ -133,10 +134,11 @@ namespace GtkSharp.Generation {
|
|||||||
if (vm_elem.GetAttributeAsBoolean ("padding") || vm_elem.GetAttributeAsBoolean ("hidden"))
|
if (vm_elem.GetAttributeAsBoolean ("padding") || vm_elem.GetAttributeAsBoolean ("hidden"))
|
||||||
hidden_vms.Add (vm);
|
hidden_vms.Add (vm);
|
||||||
else {
|
else {
|
||||||
if (vm is GObjectVM)
|
if (vm is GObjectVM) {
|
||||||
virtual_methods.Add (vm);
|
virtual_methods.Add ((GObjectVM)vm);
|
||||||
else
|
} else {
|
||||||
interface_vms.Add (vm);
|
interface_vms.Add ((InterfaceVM)vm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (vm.CName != "")
|
if (vm.CName != "")
|
||||||
class_members.Add (vm);
|
class_members.Add (vm);
|
||||||
@ -273,7 +275,7 @@ namespace GtkSharp.Generation {
|
|||||||
if (!vm.Validate (log))
|
if (!vm.Validate (log))
|
||||||
invalids.Add (vm);
|
invalids.Add (vm);
|
||||||
|
|
||||||
foreach (VirtualMethod invalid_vm in invalids) {
|
foreach (GObjectVM invalid_vm in invalids) {
|
||||||
virtual_methods.Remove (invalid_vm);
|
virtual_methods.Remove (invalid_vm);
|
||||||
hidden_vms.Add (invalid_vm);
|
hidden_vms.Add (invalid_vm);
|
||||||
}
|
}
|
||||||
|
@ -23,23 +23,26 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
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 IList<string> custom_attrs = new List<string> ();
|
||||||
private ArrayList strings = new ArrayList();
|
private IList<XmlElement> strings = new List<XmlElement> ();
|
||||||
private Hashtable childprops = new Hashtable();
|
private IDictionary<string, ChildProperty> childprops = new Dictionary<string, ChildProperty> ();
|
||||||
private static Hashtable dirs = new Hashtable ();
|
private static IDictionary<string, DirectoryInfo> dirs = new Dictionary<string, DirectoryInfo> ();
|
||||||
|
|
||||||
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;
|
XmlElement member = node as XmlElement;
|
||||||
XmlElement member = (XmlElement) node;
|
if (member == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (member.GetAttributeAsBoolean ("hidden"))
|
if (member.GetAttributeAsBoolean ("hidden"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -53,7 +56,7 @@ namespace GtkSharp.Generation {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "static-string":
|
case "static-string":
|
||||||
strings.Add (node);
|
strings.Add (member);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "childprop":
|
case "childprop":
|
||||||
@ -80,14 +83,14 @@ namespace GtkSharp.Generation {
|
|||||||
{
|
{
|
||||||
LogWriter log = new LogWriter (QualifiedName);
|
LogWriter log = new LogWriter (QualifiedName);
|
||||||
|
|
||||||
ArrayList invalids = new ArrayList ();
|
var invalids = new List<string> ();
|
||||||
|
|
||||||
foreach (ChildProperty prop in childprops.Values) {
|
foreach (string prop_name in childprops.Keys) {
|
||||||
if (!prop.Validate (log))
|
if (!childprops [prop_name].Validate (log))
|
||||||
invalids.Add (prop);
|
invalids.Add (prop_name);
|
||||||
}
|
}
|
||||||
foreach (ChildProperty prop in invalids)
|
foreach (string prop_name in invalids)
|
||||||
childprops.Remove (prop);
|
childprops.Remove (prop_name);
|
||||||
|
|
||||||
return base.Validate ();
|
return base.Validate ();
|
||||||
}
|
}
|
||||||
@ -100,11 +103,12 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
private class DirectoryInfo {
|
private class DirectoryInfo {
|
||||||
public string assembly_name;
|
public string assembly_name;
|
||||||
public Hashtable objects;
|
public IDictionary<string, string> 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 Dictionary<string, string> ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +117,7 @@ namespace GtkSharp.Generation {
|
|||||||
DirectoryInfo result;
|
DirectoryInfo result;
|
||||||
|
|
||||||
if (dirs.ContainsKey (dir)) {
|
if (dirs.ContainsKey (dir)) {
|
||||||
result = dirs [dir] as DirectoryInfo;
|
result = dirs [dir];
|
||||||
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;
|
||||||
@ -195,10 +199,11 @@ namespace GtkSharp.Generation {
|
|||||||
GenMethods (gen_info, null, null);
|
GenMethods (gen_info, null, null);
|
||||||
|
|
||||||
if (interfaces.Count != 0) {
|
if (interfaces.Count != 0) {
|
||||||
Hashtable all_methods = new Hashtable ();
|
var all_methods = new Dictionary<string, Method> ();
|
||||||
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 ();
|
}
|
||||||
|
var collisions = new Dictionary<string, bool> ();
|
||||||
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) {
|
||||||
@ -208,7 +213,8 @@ namespace GtkSharp.Generation {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Method collision = all_methods[m.Name] as Method;
|
Method collision = null;
|
||||||
|
all_methods.TryGetValue (m.Name, out collision);
|
||||||
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
|
||||||
@ -351,12 +357,14 @@ namespace GtkSharp.Generation {
|
|||||||
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 (IDictionary<string, string> 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) != objs[key]) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +383,7 @@ namespace GtkSharp.Generation {
|
|||||||
{
|
{
|
||||||
foreach (string dir in dirs.Keys) {
|
foreach (string dir in dirs.Keys) {
|
||||||
|
|
||||||
DirectoryInfo di = dirs[dir] as DirectoryInfo;
|
DirectoryInfo di = dirs[dir];
|
||||||
|
|
||||||
if (!NeedsMap (di.objects, di.assembly_name))
|
if (!NeedsMap (di.objects, di.assembly_name))
|
||||||
continue;
|
continue;
|
||||||
@ -404,8 +412,9 @@ namespace GtkSharp.Generation {
|
|||||||
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) != 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}");
|
||||||
|
@ -29,7 +29,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public class Parameters : IEnumerable<Parameter> {
|
public class Parameters : IEnumerable<Parameter> {
|
||||||
|
|
||||||
List<Parameter> param_list = new List<Parameter> ();
|
IList<Parameter> param_list = new List<Parameter> ();
|
||||||
XmlElement elem;
|
XmlElement elem;
|
||||||
bool first_is_instance;
|
bool first_is_instance;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace GtkSharp.Generation {
|
|||||||
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 ();
|
var gens = new List<IGeneratable> ();
|
||||||
|
|
||||||
foreach (XmlNode child in root.ChildNodes) {
|
foreach (XmlNode child in root.ChildNodes) {
|
||||||
XmlElement elem = child as XmlElement;
|
XmlElement elem = child as XmlElement;
|
||||||
@ -94,12 +94,12 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IGeneratable[]) gens.ToArray (typeof (IGeneratable));
|
return gens.ToArray ();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList ParseNamespace (XmlElement ns)
|
private IList<IGeneratable> ParseNamespace (XmlElement ns)
|
||||||
{
|
{
|
||||||
ArrayList result = new ArrayList ();
|
var result = new List<IGeneratable> ();
|
||||||
|
|
||||||
foreach (XmlNode def in ns.ChildNodes) {
|
foreach (XmlNode def in ns.ChildNodes) {
|
||||||
|
|
||||||
@ -121,7 +121,11 @@ namespace GtkSharp.Generation {
|
|||||||
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);
|
if (is_opaque) {
|
||||||
|
result.Add (new OpaqueGen (ns, elem));
|
||||||
|
} else {
|
||||||
|
result.Add (new BoxedGen (ns, elem));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "callback":
|
case "callback":
|
||||||
result.Add (new CallbackGen (ns, elem));
|
result.Add (new CallbackGen (ns, elem));
|
||||||
@ -139,7 +143,11 @@ namespace GtkSharp.Generation {
|
|||||||
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);
|
if (is_opaque) {
|
||||||
|
result.Add (new OpaqueGen (ns, elem));
|
||||||
|
} else {
|
||||||
|
result.Add (new StructGen (ns, elem));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine ("Parser::ParseNamespace - Unexpected node: " + def.Name);
|
Console.WriteLine ("Parser::ParseNamespace - Unexpected node: " + def.Name);
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class Signature {
|
public class Signature {
|
||||||
|
|
||||||
private ArrayList parms = new ArrayList ();
|
private IList<Parameter> parms = new List<Parameter> ();
|
||||||
|
|
||||||
public Signature (Parameters parms)
|
public Signature (Parameters parms)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -30,7 +30,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public abstract class StructBase : ClassBase, IManualMarshaler {
|
public abstract class StructBase : ClassBase, IManualMarshaler {
|
||||||
|
|
||||||
new ArrayList fields = new ArrayList ();
|
new IList<StructField> fields = new List<StructField> ();
|
||||||
bool need_read_native = false;
|
bool need_read_native = false;
|
||||||
|
|
||||||
protected StructBase (XmlElement ns, XmlElement elem) : base (ns, elem)
|
protected StructBase (XmlElement ns, XmlElement elem) : base (ns, elem)
|
||||||
|
@ -23,13 +23,13 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class SymbolTable {
|
public class SymbolTable {
|
||||||
|
|
||||||
static SymbolTable table = null;
|
static SymbolTable table = null;
|
||||||
|
|
||||||
Hashtable types = new Hashtable ();
|
IDictionary<string, IGeneratable> types = new Dictionary<string, IGeneratable> ();
|
||||||
|
|
||||||
public static SymbolTable Table {
|
public static SymbolTable Table {
|
||||||
get {
|
get {
|
||||||
@ -168,7 +168,7 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable Generatables {
|
public IEnumerable<IGeneratable> Generatables {
|
||||||
get {
|
get {
|
||||||
return types.Values;
|
return types.Values;
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
public IGeneratable this [string ctype] {
|
public IGeneratable this [string ctype] {
|
||||||
get {
|
get {
|
||||||
return DeAlias (ctype) as IGeneratable;
|
return DeAlias (ctype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,16 +208,17 @@ namespace GtkSharp.Generation {
|
|||||||
return trim_type;
|
return trim_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private object DeAlias (string type)
|
private IGeneratable DeAlias (string type)
|
||||||
{
|
{
|
||||||
type = Trim (type);
|
type = Trim (type);
|
||||||
while (types [type] is AliasGen) {
|
IGeneratable cur_type = null;
|
||||||
|
while (types.TryGetValue (type, out cur_type) && cur_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 cur_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FromNative(string c_type, string val)
|
public string FromNative(string c_type, string val)
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class VMSignature {
|
public class VMSignature {
|
||||||
|
|
||||||
private ArrayList parms = new ArrayList ();
|
private IList<Parameter> parms = new List<Parameter> ();
|
||||||
|
|
||||||
public VMSignature (Parameters parms)
|
public VMSignature (Parameters parms)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user