mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 03:05:30 +00:00
Fixed enum generation.
This commit is contained in:
parent
687140323e
commit
cb06e36785
|
@ -76,7 +76,6 @@ namespace Bind
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
WriteDefinitions(sw, enums, wrappers, Type.CSTypes);
|
WriteDefinitions(sw, enums, wrappers, Type.CSTypes);
|
||||||
WriteEnums(sw, enums);
|
|
||||||
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
sw.Close();
|
sw.Close();
|
||||||
|
@ -127,6 +126,8 @@ namespace Bind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteEnums(sw, enums);
|
||||||
|
|
||||||
sw.Unindent();
|
sw.Unindent();
|
||||||
sw.WriteLine("}");
|
sw.WriteLine("}");
|
||||||
}
|
}
|
||||||
|
@ -142,13 +143,18 @@ namespace Bind
|
||||||
sw.WriteLine("public enum {0}", @enum.Name);
|
sw.WriteLine("public enum {0}", @enum.Name);
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
sw.Indent();
|
sw.Indent();
|
||||||
|
int count = @enum.ConstantCollection.Values.Count;
|
||||||
foreach (var c in @enum.ConstantCollection.Values)
|
foreach (var c in @enum.ConstantCollection.Values)
|
||||||
{
|
{
|
||||||
sw.WriteLine(String.Format("{0} = {1}{2},",
|
sw.WriteLine(String.Format("{0}({1}{2}){3}",
|
||||||
c.Name,
|
c.Name,
|
||||||
!String.IsNullOrEmpty(c.Reference) ? (c.Reference + Settings.NamespaceSeparator) : "",
|
!String.IsNullOrEmpty(c.Reference) ? (c.Reference + Settings.NamespaceSeparator) : "",
|
||||||
c.Value));
|
!String.IsNullOrEmpty(c.Reference) ? c.Value : c.Value.ToLower(),
|
||||||
|
--count == 0 ? ";" : ","));
|
||||||
}
|
}
|
||||||
|
sw.WriteLine();
|
||||||
|
sw.WriteLine("{0} mValue;", @enum.Type);
|
||||||
|
sw.WriteLine("{0}({1} value) {{ mValue = value; }}", @enum.Name, @enum.Type);
|
||||||
sw.Unindent();
|
sw.Unindent();
|
||||||
sw.WriteLine("}");
|
sw.WriteLine("}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
@ -200,27 +206,41 @@ namespace Bind
|
||||||
valid = true;
|
valid = true;
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
if (f.TrimmedName == "ExtGetBufferPointer")
|
||||||
|
;// Debugger.Break();
|
||||||
|
|
||||||
if (f.Parameters.Count > 0)
|
if (f.Parameters.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var p in f.Parameters)
|
foreach (var p in f.Parameters)
|
||||||
{
|
{
|
||||||
if (p.Reference)
|
if (p.Reference)
|
||||||
{
|
{
|
||||||
if (p.Flow == FlowDirection.Out)
|
// Use a boxed type instead of primitives (i.e. "Byte" rather than "byte"), since
|
||||||
sb.Append("Out<");
|
// the former are reference types. We don't need to do anything for regular reference
|
||||||
|
// types.
|
||||||
|
// Hack: we do this by upper-casing the first letter of the type. This should work for
|
||||||
|
// all primitive types, but won't work for enums and other reference types. In these
|
||||||
|
// cases, we'll just ignore the reference overload.
|
||||||
|
if (Char.IsLower(p.CurrentType[0]))
|
||||||
|
{
|
||||||
|
// Hack: Int -> Integer and Bool -> Boolean
|
||||||
|
if (p.CurrentType == "int")
|
||||||
|
sb.Append("Integer");
|
||||||
|
else if (p.CurrentType == "bool")
|
||||||
|
sb.Append("Boolean");
|
||||||
else
|
else
|
||||||
sb.Append("Ref<");
|
|
||||||
|
|
||||||
// Hack: primitive types cannot be used as type parameters in Java.
|
|
||||||
// Ensure the first letter is upper-case in order to use the boxed versions
|
|
||||||
// of primitive types (i.e. "Byte" rather than "byte" etc).
|
|
||||||
sb.Append(Char.ToUpper(p.CurrentType[0]) + p.CurrentType.Substring(1));
|
sb.Append(Char.ToUpper(p.CurrentType[0]) + p.CurrentType.Substring(1));
|
||||||
sb.Append(">");
|
|
||||||
}
|
}
|
||||||
else if (p.Pointer > 0 && p.Array > 0)
|
else
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (p.Array > 0)
|
||||||
{
|
{
|
||||||
sb.Append(p.CurrentType);
|
sb.Append(p.CurrentType);
|
||||||
if (p.Array > 0)
|
for (int i = 0; i < p.Array; i++)
|
||||||
sb.Append("[]");
|
sb.Append("[]");
|
||||||
}
|
}
|
||||||
else if (p.Pointer > 0)
|
else if (p.Pointer > 0)
|
||||||
|
|
Loading…
Reference in a new issue