* Main.cs:
* CL/CLGenerator.cs: Made CLGenerator inherit from ESGenerator. Reduces code duplication significantly.
This commit is contained in:
parent
80e385b98b
commit
79b6329ff5
2 changed files with 5 additions and 105 deletions
|
@ -9,28 +9,14 @@ using Enum=Bind.Structures.Enum;
|
||||||
|
|
||||||
namespace Bind.CL
|
namespace Bind.CL
|
||||||
{
|
{
|
||||||
class CLGenerator : Generator
|
class CLGenerator : ES.ESGenerator
|
||||||
{
|
{
|
||||||
public CLGenerator(string name)
|
public CLGenerator(string name, string dirname)
|
||||||
|
: base(name, dirname)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(name))
|
|
||||||
throw new ArgumentNullException("name");
|
|
||||||
|
|
||||||
glTypemap = null;
|
glTypemap = null;
|
||||||
csTypemap = "csharp.tm";
|
|
||||||
|
|
||||||
enumSpec = name + "/signatures.xml";
|
|
||||||
enumSpecExt = String.Empty;
|
|
||||||
glSpec = name + "/signatures.xml";
|
|
||||||
glSpecExt = String.Empty;
|
|
||||||
functionOverridesFile = name + "/overrides.xml";
|
|
||||||
|
|
||||||
importsFile = "Core.cs";
|
|
||||||
delegatesFile = "Delegates.cs";
|
|
||||||
enumsFile = "Enums.cs";
|
|
||||||
wrappersFile = "CL.cs";
|
wrappersFile = "CL.cs";
|
||||||
Settings.ImportsClass = "Core";
|
|
||||||
Settings.DelegatesClass = "Delegates";
|
|
||||||
|
|
||||||
Settings.FunctionPrefix = "cl";
|
Settings.FunctionPrefix = "cl";
|
||||||
Settings.ConstantPrefix = "CL_";
|
Settings.ConstantPrefix = "CL_";
|
||||||
|
@ -38,95 +24,9 @@ namespace Bind.CL
|
||||||
|
|
||||||
Settings.OutputClass = "CL";
|
Settings.OutputClass = "CL";
|
||||||
Settings.OutputNamespace = "OpenTK.Compute." + name;
|
Settings.OutputNamespace = "OpenTK.Compute." + name;
|
||||||
Settings.OutputPath = Path.Combine("../../../Source/OpenTK/Compute", name);
|
|
||||||
|
|
||||||
//Settings.Compatibility &= ~Settings.Legacy.TurnVoidPointersToIntPtr;
|
//Settings.Compatibility &= ~Settings.Legacy.TurnVoidPointersToIntPtr;
|
||||||
Settings.Compatibility |= Settings.Legacy.NoDebugHelpers;
|
Settings.Compatibility |= Settings.Legacy.NoDebugHelpers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override DelegateCollection ReadDelegates(StreamReader specFile)
|
|
||||||
{
|
|
||||||
DelegateCollection delegates = new DelegateCollection();
|
|
||||||
|
|
||||||
XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile)));
|
|
||||||
|
|
||||||
XPathNavigator nav = new XPathDocument(specFile).CreateNavigator().SelectSingleNode("/signatures");
|
|
||||||
|
|
||||||
foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
|
|
||||||
{
|
|
||||||
Delegate d = new Delegate();
|
|
||||||
d.Name = node.GetAttribute("name", String.Empty);
|
|
||||||
//d.Extension = node.GetAttribute("extension");
|
|
||||||
d.Version = node.GetAttribute("version", String.Empty);
|
|
||||||
d.Category = node.GetAttribute("category", String.Empty);
|
|
||||||
foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
|
|
||||||
{
|
|
||||||
switch (param.Name)
|
|
||||||
{
|
|
||||||
case "returns":
|
|
||||||
d.ReturnType.CurrentType = param.GetAttribute("type", String.Empty);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "param":
|
|
||||||
Parameter p = new Parameter();
|
|
||||||
p.CurrentType = param.GetAttribute("type", String.Empty);
|
|
||||||
p.Name = param.GetAttribute("name", String.Empty);
|
|
||||||
|
|
||||||
string element_count = param.GetAttribute("elementcount", String.Empty);
|
|
||||||
if (!String.IsNullOrEmpty(element_count))
|
|
||||||
p.ElementCount = Int32.Parse(element_count);
|
|
||||||
|
|
||||||
p.Flow = Parameter.GetFlowDirection(param.GetAttribute("flow", String.Empty));
|
|
||||||
|
|
||||||
d.Parameters.Add(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
d.Translate(overrides);
|
|
||||||
delegates.Add(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
return delegates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Dictionary<string, string> ReadTypeMap(StreamReader specFile)
|
|
||||||
{
|
|
||||||
return base.ReadTypeMap(specFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Dictionary<string, string> ReadCSTypeMap(StreamReader specFile)
|
|
||||||
{
|
|
||||||
return base.ReadCSTypeMap(specFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override EnumCollection ReadEnums(StreamReader specFile)
|
|
||||||
{
|
|
||||||
XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile)));
|
|
||||||
|
|
||||||
EnumCollection enums = new EnumCollection();
|
|
||||||
Enum all = new Enum(Settings.CompleteEnumName);
|
|
||||||
XPathDocument doc = new XPathDocument(specFile);
|
|
||||||
XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("/signatures");
|
|
||||||
|
|
||||||
foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty))
|
|
||||||
{
|
|
||||||
Enum e = new Enum(node.GetAttribute("name", String.Empty));
|
|
||||||
if (String.IsNullOrEmpty(e.Name))
|
|
||||||
throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString()));
|
|
||||||
|
|
||||||
foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
|
|
||||||
{
|
|
||||||
Constant c = new Constant(param.GetAttribute("name", String.Empty), param.GetAttribute("value", String.Empty));
|
|
||||||
Utilities.Merge(all, c);
|
|
||||||
e.ConstantCollection.Add(c.Name, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
Utilities.Merge(enums, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Utilities.Merge(enums, all);
|
|
||||||
enums.Translate(overrides);
|
|
||||||
return enums;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace Bind
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GeneratorMode.CL10:
|
case GeneratorMode.CL10:
|
||||||
Generator = new CLGenerator("CL10");
|
Generator = new CLGenerator("CL10", dirName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GeneratorMode.Wgl:
|
case GeneratorMode.Wgl:
|
||||||
|
|
Loading…
Reference in a new issue