mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 18:25:30 +00:00
* CppSpecWriter.cs: Improved C++ output (still needs work).
This commit is contained in:
parent
4ef1407f04
commit
863e2b6542
|
@ -56,21 +56,19 @@ namespace Bind
|
||||||
if (!Directory.Exists(Settings.OutputPath))
|
if (!Directory.Exists(Settings.OutputPath))
|
||||||
Directory.CreateDirectory(Settings.OutputPath);
|
Directory.CreateDirectory(Settings.OutputPath);
|
||||||
|
|
||||||
|
Settings.DefaultOutputNamespace = "OpenTK";
|
||||||
|
|
||||||
string temp_core_file = Path.GetTempFileName();
|
string temp_core_file = Path.GetTempFileName();
|
||||||
|
|
||||||
using (BindStreamWriter sw = new BindStreamWriter(temp_core_file))
|
using (BindStreamWriter sw = new BindStreamWriter(temp_core_file))
|
||||||
{
|
{
|
||||||
WriteLicense(sw);
|
WriteLicense(sw);
|
||||||
|
|
||||||
sw.WriteLine("namespace {0}", "gl");
|
sw.WriteLine("namespace {0}", Settings.OutputNamespace);
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
sw.Indent();
|
sw.Indent();
|
||||||
|
|
||||||
sw.Indent();
|
|
||||||
WriteEnums(sw, enums);
|
WriteEnums(sw, enums);
|
||||||
sw.Unindent();
|
|
||||||
|
|
||||||
//WriteDelegates(sw, delegates);
|
|
||||||
WriteWrappers(sw, wrappers, Type.CSTypes);
|
WriteWrappers(sw, wrappers, Type.CSTypes);
|
||||||
|
|
||||||
sw.Unindent();
|
sw.Unindent();
|
||||||
|
@ -111,27 +109,41 @@ namespace Bind
|
||||||
|
|
||||||
public void WriteWrappers(BindStreamWriter sw, FunctionCollection wrappers, Dictionary<string, string> CSTypes)
|
public void WriteWrappers(BindStreamWriter sw, FunctionCollection wrappers, Dictionary<string, string> CSTypes)
|
||||||
{
|
{
|
||||||
|
sw.WriteLine("struct {0}", Settings.GLClass);
|
||||||
|
sw.WriteLine("{");
|
||||||
|
sw.Indent();
|
||||||
|
|
||||||
foreach (string extension in wrappers.Keys)
|
foreach (string extension in wrappers.Keys)
|
||||||
{
|
{
|
||||||
if (extension != "Core")
|
if (extension != "Core")
|
||||||
{
|
{
|
||||||
sw.WriteLine("namespace {0}", extension);
|
sw.WriteLine("struct {0}", extension);
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
sw.Indent();
|
sw.Indent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Delegate last_delegate = null;
|
||||||
foreach (Function f in wrappers[extension])
|
foreach (Function f in wrappers[extension])
|
||||||
{
|
{
|
||||||
sw.WriteLine("static {0} (* p{1})({2});", f.ReturnType, f.TrimmedName, f.Parameters);
|
var d = f.WrappedDelegate;
|
||||||
|
// Avoid multiple definitions of the same function
|
||||||
|
if (d != last_delegate)
|
||||||
|
{
|
||||||
|
last_delegate = d;
|
||||||
|
sw.WriteLine("static {0} (*p{1})({2});", d.ReturnType, f.TrimmedName, d.Parameters);
|
||||||
sw.WriteLine("extern p{0} {0};", f.TrimmedName);
|
sw.WriteLine("extern p{0} {0};", f.TrimmedName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (extension != "Core")
|
if (extension != "Core")
|
||||||
{
|
{
|
||||||
sw.Unindent();
|
sw.Unindent();
|
||||||
sw.WriteLine("}");
|
sw.WriteLine("};");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
@ -218,9 +230,15 @@ namespace Bind
|
||||||
{
|
{
|
||||||
foreach (Enum @enum in enums.Values)
|
foreach (Enum @enum in enums.Values)
|
||||||
{
|
{
|
||||||
sw.Write("enum ");
|
sw.Write("struct ");
|
||||||
sw.Write(@enum.Name);
|
sw.Write(@enum.Name);
|
||||||
sw.Write("{");
|
sw.Write(" : Enumeration<");
|
||||||
|
sw.Write(@enum.Name);
|
||||||
|
sw.WriteLine(">");
|
||||||
|
sw.WriteLine("{");
|
||||||
|
sw.Indent();
|
||||||
|
sw.WriteLine("enum ");
|
||||||
|
sw.WriteLine("{");
|
||||||
sw.Indent();
|
sw.Indent();
|
||||||
foreach (var c in @enum.ConstantCollection.Values)
|
foreach (var c in @enum.ConstantCollection.Values)
|
||||||
{
|
{
|
||||||
|
@ -229,6 +247,8 @@ namespace Bind
|
||||||
}
|
}
|
||||||
sw.Unindent();
|
sw.Unindent();
|
||||||
sw.WriteLine("};");
|
sw.WriteLine("};");
|
||||||
|
sw.Unindent();
|
||||||
|
sw.WriteLine("};");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue