Do not rely on JNA types that are not available on Android.
Replaced generic multiple wrappers by a single Buffer wrapper.
This commit is contained in:
parent
cb06e36785
commit
082fc8c422
1 changed files with 40 additions and 18 deletions
|
@ -74,6 +74,8 @@ namespace Bind
|
||||||
|
|
||||||
sw.WriteLine("package {0}.{1};", Settings.OutputNamespace, Settings.GLClass);
|
sw.WriteLine("package {0}.{1};", Settings.OutputNamespace, Settings.GLClass);
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
sw.WriteLine("import java.nio.*;");
|
||||||
|
sw.WriteLine();
|
||||||
|
|
||||||
WriteDefinitions(sw, enums, wrappers, Type.CSTypes);
|
WriteDefinitions(sw, enums, wrappers, Type.CSTypes);
|
||||||
|
|
||||||
|
@ -144,17 +146,25 @@ namespace Bind
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
sw.Indent();
|
sw.Indent();
|
||||||
int count = @enum.ConstantCollection.Values.Count;
|
int count = @enum.ConstantCollection.Values.Count;
|
||||||
foreach (var c in @enum.ConstantCollection.Values)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
sw.WriteLine(String.Format("{0}({1}{2}){3}",
|
// Java enums must have at least one value.
|
||||||
c.Name,
|
sw.WriteLine("None;");
|
||||||
!String.IsNullOrEmpty(c.Reference) ? (c.Reference + Settings.NamespaceSeparator) : "",
|
}
|
||||||
!String.IsNullOrEmpty(c.Reference) ? c.Value : c.Value.ToLower(),
|
else
|
||||||
--count == 0 ? ";" : ","));
|
{
|
||||||
|
foreach (var c in @enum.ConstantCollection.Values)
|
||||||
|
{
|
||||||
|
sw.WriteLine(String.Format("{0}({1}{2}){3}",
|
||||||
|
c.Name,
|
||||||
|
!String.IsNullOrEmpty(c.Reference) ? (c.Reference + Settings.NamespaceSeparator) : "",
|
||||||
|
!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.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();
|
||||||
|
@ -170,14 +180,15 @@ namespace Bind
|
||||||
var valid = true;
|
var valid = true;
|
||||||
var generic_parameters = GenerateGenericTypeString(f);
|
var generic_parameters = GenerateGenericTypeString(f);
|
||||||
var parameters = GenerateParameterString(f, out valid);
|
var parameters = GenerateParameterString(f, out valid);
|
||||||
|
var ret_parameter = GenerateReturnParameterString(f);
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(generic_parameters))
|
if (!String.IsNullOrEmpty(generic_parameters))
|
||||||
sw.WriteLine("public static <{0}> {1} {2}({3})", generic_parameters,
|
sw.WriteLine("public static <{0}> {1} {2}({3})", generic_parameters,
|
||||||
f.ReturnType, f.TrimmedName, parameters);
|
ret_parameter, f.TrimmedName, parameters);
|
||||||
else
|
else
|
||||||
sw.WriteLine("public static {0} {1}({2})", f.ReturnType, f.TrimmedName,
|
sw.WriteLine("public static {0} {1}({2})", ret_parameter, f.TrimmedName,
|
||||||
parameters);
|
parameters);
|
||||||
|
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
|
@ -196,8 +207,6 @@ namespace Bind
|
||||||
// sw.WriteLine("GLES20.{0}{1};", f.WrappedDelegate.Name, callstring);
|
// sw.WriteLine("GLES20.{0}{1};", f.WrappedDelegate.Name, callstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region GenerateParameterString
|
|
||||||
|
|
||||||
static string GenerateParameterString(Function f, out bool valid)
|
static string GenerateParameterString(Function f, out bool valid)
|
||||||
{
|
{
|
||||||
if (f == null)
|
if (f == null)
|
||||||
|
@ -239,6 +248,13 @@ namespace Bind
|
||||||
}
|
}
|
||||||
else if (p.Array > 0)
|
else if (p.Array > 0)
|
||||||
{
|
{
|
||||||
|
// Generic arrays are handled in the IntPtr case below.
|
||||||
|
if (p.Generic)
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
sb.Append(p.CurrentType);
|
sb.Append(p.CurrentType);
|
||||||
for (int i = 0; i < p.Array; i++)
|
for (int i = 0; i < p.Array; i++)
|
||||||
sb.Append("[]");
|
sb.Append("[]");
|
||||||
|
@ -250,6 +266,10 @@ namespace Bind
|
||||||
valid = false;
|
valid = false;
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
else if (p.CurrentType == "IntPtr")
|
||||||
|
{
|
||||||
|
sb.Append("Buffer");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.Append(p.CurrentType);
|
sb.Append(p.CurrentType);
|
||||||
|
@ -267,10 +287,6 @@ namespace Bind
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region GenerateGenericTypeString
|
|
||||||
|
|
||||||
static string GenerateGenericTypeString(Function f)
|
static string GenerateGenericTypeString(Function f)
|
||||||
{
|
{
|
||||||
var parameters = f.Parameters.Where(p => p.Generic);
|
var parameters = f.Parameters.Where(p => p.Generic);
|
||||||
|
@ -291,7 +307,13 @@ namespace Bind
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
private static string GenerateReturnParameterString(Function f)
|
||||||
|
{
|
||||||
|
if (f.ReturnType.CurrentType == "IntPtr")
|
||||||
|
return "Buffer";
|
||||||
|
else
|
||||||
|
return f.ReturnType.CurrentType;
|
||||||
|
}
|
||||||
|
|
||||||
static DocProcessor processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile));
|
static DocProcessor processor = new DocProcessor(Path.Combine(Settings.DocPath, Settings.DocFile));
|
||||||
static Dictionary<string, string> docfiles;
|
static Dictionary<string, string> docfiles;
|
||||||
|
|
Loading…
Reference in a new issue