mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 01:25:31 +00:00
Saner handling of various settings.
Improved C++ spec writer (still needs a lot of work).
This commit is contained in:
parent
c412f93700
commit
0eef1c3629
|
@ -58,12 +58,11 @@ namespace Bind
|
|||
|
||||
string temp_core_file = Path.GetTempFileName();
|
||||
|
||||
// Enums
|
||||
using (BindStreamWriter sw = new BindStreamWriter(temp_core_file))
|
||||
{
|
||||
WriteLicense(sw);
|
||||
|
||||
sw.WriteLine("namespace {0}", Settings.OutputNamespace);
|
||||
sw.WriteLine("namespace {0}", "gl");
|
||||
sw.WriteLine("{");
|
||||
sw.Indent();
|
||||
|
||||
|
@ -71,13 +70,14 @@ namespace Bind
|
|||
WriteEnums(sw, enums);
|
||||
sw.Unindent();
|
||||
|
||||
WriteDelegates(sw, delegates);
|
||||
//WriteDelegates(sw, delegates);
|
||||
WriteWrappers(sw, wrappers, Type.CSTypes);
|
||||
|
||||
sw.Unindent();
|
||||
sw.WriteLine("}");
|
||||
}
|
||||
|
||||
string output_core = Path.Combine(Settings.OutputPath, Settings.ImportsFile);
|
||||
string output_core = Path.Combine(Settings.OutputPath, "gl.h");
|
||||
if (File.Exists(output_core))
|
||||
File.Delete(output_core);
|
||||
File.Move(temp_core_file, output_core);
|
||||
|
@ -93,7 +93,7 @@ namespace Bind
|
|||
|
||||
foreach (Delegate d in delegates.Values)
|
||||
{
|
||||
sw.WriteLine("extern {0};", d.ToString());
|
||||
sw.WriteLine("extern {0} {1}({2});", d.ReturnType, d.Name, d.Parameters);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,27 @@ namespace Bind
|
|||
|
||||
public void WriteWrappers(BindStreamWriter sw, FunctionCollection wrappers, Dictionary<string, string> CSTypes)
|
||||
{
|
||||
foreach (string extension in wrappers.Keys)
|
||||
{
|
||||
if (extension != "Core")
|
||||
{
|
||||
sw.WriteLine("namespace {0}", extension);
|
||||
sw.WriteLine("{");
|
||||
sw.Indent();
|
||||
}
|
||||
|
||||
foreach (Function f in wrappers[extension])
|
||||
{
|
||||
sw.WriteLine("static {0} (* p{1})({2});", f.ReturnType, f.TrimmedName, f.Parameters);
|
||||
sw.WriteLine("extern p{0} {0};", f.TrimmedName);
|
||||
}
|
||||
|
||||
if (extension != "Core")
|
||||
{
|
||||
sw.Unindent();
|
||||
sw.WriteLine("}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static DocProcessor processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile));
|
||||
|
@ -195,31 +216,21 @@ namespace Bind
|
|||
|
||||
public void WriteEnums(BindStreamWriter sw, EnumCollection enums)
|
||||
{
|
||||
//sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute
|
||||
sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments
|
||||
sw.WriteLine();
|
||||
|
||||
Trace.WriteLine(String.Format("Writing enums to:\t{0}", Settings.EnumsOutput));
|
||||
|
||||
sw.WriteLine("namespace gl");
|
||||
sw.WriteLine("{");
|
||||
sw.Indent();
|
||||
|
||||
foreach (Enum @enum in enums.Values)
|
||||
{
|
||||
sw.Write("enum ");
|
||||
sw.Write(@enum.Name);
|
||||
sw.Write("{");
|
||||
sw.Indent();
|
||||
foreach (var c in @enum.ConstantCollection)
|
||||
sw.WriteLine(c);
|
||||
foreach (var c in @enum.ConstantCollection.Values)
|
||||
{
|
||||
sw.Write(c);
|
||||
sw.WriteLine(",");
|
||||
}
|
||||
sw.Unindent();
|
||||
sw.WriteLine("};");
|
||||
sw.WriteLine();
|
||||
}
|
||||
|
||||
sw.Unindent();
|
||||
sw.WriteLine("}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -36,9 +36,6 @@ namespace Bind.ES
|
|||
|
||||
Settings.OutputClass = "GL";
|
||||
Settings.OutputNamespace = "OpenTK.Graphics." + nsName;
|
||||
Settings.DefaultOutputPath = Path.Combine(
|
||||
Directory.GetParent(Settings.DefaultOutputPath).ToString(),
|
||||
dirName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,6 @@ namespace Bind.GL2
|
|||
Settings.DelegatesClass = "Delegates";
|
||||
|
||||
Settings.OutputClass = "GL";
|
||||
Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
|
||||
Settings.DefaultOutputPath = "../../../Source/OpenTK/Graphics/OpenGL";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,24 +82,18 @@ namespace Bind
|
|||
{
|
||||
string arg = b[1].ToLower();
|
||||
if (arg == "cpp" || arg == "c++" || arg == "c")
|
||||
{
|
||||
lang = GeneratorLanguage.Cpp;
|
||||
Settings.DefaultOutputPath = "gl";
|
||||
Settings.DefaultOutputNamespace = "gl";
|
||||
Settings.EnumsNamespace = "gl";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "mode":
|
||||
{
|
||||
string arg = b[1].ToLower();
|
||||
if (arg == "gl" || arg == "gl2" || arg == "gl3" || arg == "gl4")
|
||||
mode = GeneratorMode.GL2;
|
||||
else if (arg == "es10")
|
||||
mode = GeneratorMode.ES10;
|
||||
else if (arg == "es11")
|
||||
mode = GeneratorMode.ES11;
|
||||
else if (arg == "es20")
|
||||
mode = GeneratorMode.ES20;
|
||||
else if (arg == "cl" || arg == "cl10")
|
||||
mode = GeneratorMode.CL10;
|
||||
else
|
||||
throw new NotImplementedException();
|
||||
SetGeneratorMode(dirName, arg);
|
||||
if (b.Length > 2)
|
||||
dirName = b[2];
|
||||
break;
|
||||
|
@ -176,7 +170,6 @@ namespace Bind
|
|||
default:
|
||||
Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl3/glu/wgl/glx])'");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Generator.Process();
|
||||
|
@ -217,6 +210,44 @@ namespace Bind
|
|||
}
|
||||
}
|
||||
|
||||
private static void SetGeneratorMode(string dirName, string arg)
|
||||
{
|
||||
if (arg == "gl" || arg == "gl2" || arg == "gl3" || arg == "gl4")
|
||||
{
|
||||
mode = GeneratorMode.GL2;
|
||||
Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
|
||||
}
|
||||
else if (arg == "es10")
|
||||
{
|
||||
mode = GeneratorMode.ES10;
|
||||
Settings.DefaultOutputPath = Path.Combine(
|
||||
Directory.GetParent(Settings.DefaultOutputPath).ToString(),
|
||||
dirName);
|
||||
}
|
||||
else if (arg == "es11")
|
||||
{
|
||||
mode = GeneratorMode.ES11;
|
||||
Settings.DefaultOutputPath = Path.Combine(
|
||||
Directory.GetParent(Settings.DefaultOutputPath).ToString(),
|
||||
dirName);
|
||||
}
|
||||
else if (arg == "es20")
|
||||
{
|
||||
mode = GeneratorMode.ES20;
|
||||
Settings.DefaultOutputPath = Path.Combine(
|
||||
Directory.GetParent(Settings.DefaultOutputPath).ToString(),
|
||||
dirName);
|
||||
}
|
||||
else if (arg == "cl" || arg == "cl10")
|
||||
{
|
||||
mode = GeneratorMode.CL10;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
private static void ShowHelp()
|
||||
{
|
||||
Console.WriteLine(
|
||||
|
|
|
@ -346,10 +346,8 @@ namespace Bind.Structures
|
|||
}
|
||||
else
|
||||
{
|
||||
//if (aux)
|
||||
// CurrentType = EnumProcessor.TranslateEnumName(CurrentType);
|
||||
|
||||
#warning "Unecessary code"
|
||||
// Some functions and enums have the same names.
|
||||
// Make sure we reference the enums rather than the functions.
|
||||
if (normal)
|
||||
QualifiedType = CurrentType.Insert(0, String.Format("{0}.", Settings.EnumsOutput));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue