mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-09 22:27:35 +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();
|
string temp_core_file = Path.GetTempFileName();
|
||||||
|
|
||||||
// Enums
|
|
||||||
using (BindStreamWriter sw = new BindStreamWriter(temp_core_file))
|
using (BindStreamWriter sw = new BindStreamWriter(temp_core_file))
|
||||||
{
|
{
|
||||||
WriteLicense(sw);
|
WriteLicense(sw);
|
||||||
|
|
||||||
sw.WriteLine("namespace {0}", Settings.OutputNamespace);
|
sw.WriteLine("namespace {0}", "gl");
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
sw.Indent();
|
sw.Indent();
|
||||||
|
|
||||||
|
@ -71,13 +70,14 @@ namespace Bind
|
||||||
WriteEnums(sw, enums);
|
WriteEnums(sw, enums);
|
||||||
sw.Unindent();
|
sw.Unindent();
|
||||||
|
|
||||||
WriteDelegates(sw, delegates);
|
//WriteDelegates(sw, delegates);
|
||||||
|
WriteWrappers(sw, wrappers, Type.CSTypes);
|
||||||
|
|
||||||
sw.Unindent();
|
sw.Unindent();
|
||||||
sw.WriteLine("}");
|
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))
|
if (File.Exists(output_core))
|
||||||
File.Delete(output_core);
|
File.Delete(output_core);
|
||||||
File.Move(temp_core_file, output_core);
|
File.Move(temp_core_file, output_core);
|
||||||
|
@ -93,7 +93,7 @@ namespace Bind
|
||||||
|
|
||||||
foreach (Delegate d in delegates.Values)
|
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)
|
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));
|
static DocProcessor processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile));
|
||||||
|
@ -195,31 +216,21 @@ namespace Bind
|
||||||
|
|
||||||
public void WriteEnums(BindStreamWriter sw, EnumCollection enums)
|
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)
|
foreach (Enum @enum in enums.Values)
|
||||||
{
|
{
|
||||||
sw.Write("enum ");
|
sw.Write("enum ");
|
||||||
sw.Write(@enum.Name);
|
sw.Write(@enum.Name);
|
||||||
sw.Write("{");
|
sw.Write("{");
|
||||||
sw.Indent();
|
sw.Indent();
|
||||||
foreach (var c in @enum.ConstantCollection)
|
foreach (var c in @enum.ConstantCollection.Values)
|
||||||
sw.WriteLine(c);
|
{
|
||||||
|
sw.Write(c);
|
||||||
|
sw.WriteLine(",");
|
||||||
|
}
|
||||||
sw.Unindent();
|
sw.Unindent();
|
||||||
sw.WriteLine("};");
|
sw.WriteLine("};");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Unindent();
|
|
||||||
sw.WriteLine("}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -36,9 +36,6 @@ namespace Bind.ES
|
||||||
|
|
||||||
Settings.OutputClass = "GL";
|
Settings.OutputClass = "GL";
|
||||||
Settings.OutputNamespace = "OpenTK.Graphics." + nsName;
|
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.DelegatesClass = "Delegates";
|
||||||
|
|
||||||
Settings.OutputClass = "GL";
|
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();
|
string arg = b[1].ToLower();
|
||||||
if (arg == "cpp" || arg == "c++" || arg == "c")
|
if (arg == "cpp" || arg == "c++" || arg == "c")
|
||||||
|
{
|
||||||
lang = GeneratorLanguage.Cpp;
|
lang = GeneratorLanguage.Cpp;
|
||||||
|
Settings.DefaultOutputPath = "gl";
|
||||||
|
Settings.DefaultOutputNamespace = "gl";
|
||||||
|
Settings.EnumsNamespace = "gl";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "mode":
|
case "mode":
|
||||||
{
|
{
|
||||||
string arg = b[1].ToLower();
|
string arg = b[1].ToLower();
|
||||||
if (arg == "gl" || arg == "gl2" || arg == "gl3" || arg == "gl4")
|
SetGeneratorMode(dirName, arg);
|
||||||
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();
|
|
||||||
if (b.Length > 2)
|
if (b.Length > 2)
|
||||||
dirName = b[2];
|
dirName = b[2];
|
||||||
break;
|
break;
|
||||||
|
@ -176,7 +170,6 @@ namespace Bind
|
||||||
default:
|
default:
|
||||||
Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl3/glu/wgl/glx])'");
|
Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl3/glu/wgl/glx])'");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Generator.Process();
|
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()
|
private static void ShowHelp()
|
||||||
{
|
{
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
|
|
|
@ -346,10 +346,8 @@ namespace Bind.Structures
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//if (aux)
|
// Some functions and enums have the same names.
|
||||||
// CurrentType = EnumProcessor.TranslateEnumName(CurrentType);
|
// Make sure we reference the enums rather than the functions.
|
||||||
|
|
||||||
#warning "Unecessary code"
|
|
||||||
if (normal)
|
if (normal)
|
||||||
QualifiedType = CurrentType.Insert(0, String.Format("{0}.", Settings.EnumsOutput));
|
QualifiedType = CurrentType.Insert(0, String.Format("{0}.", Settings.EnumsOutput));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue