Permalink
Browse files

Generic type parameters cannot be primitive types in Java. Fixed!

git-svn-id: https://opentk.svn.sourceforge.net/svnroot/opentk/trunk@3099 ebc5dd9b-fb1d-0410-b6f8-d24c324e9604
  • Loading branch information...
1 parent db172f7 commit 586897222778da7ba42e537b10bc3abda9bf77a7 the_fiddler committed Dec 5, 2011
Showing with 7 additions and 4 deletions.
  1. +7 −4 Source/Bind/JavaSpecWriter.cs
View
11 Source/Bind/JavaSpecWriter.cs
@@ -162,7 +162,7 @@ public void WriteEnums(BindStreamWriter sw, EnumCollection enums)
static void WriteWrapper(Function f, BindStreamWriter sw)
{
var valid = true;
- var generic_parameters = GenerateGenericParameterString(f);
+ var generic_parameters = GenerateGenericTypeString(f);
var parameters = GenerateParameterString(f, out valid);
if (!valid)
return;
@@ -211,7 +211,10 @@ static string GenerateParameterString(Function f, out bool valid)
else
sb.Append("Ref<");
- sb.Append(p.CurrentType);
+ // 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(">");
}
else if (p.Pointer > 0 && p.Array > 0)
@@ -246,9 +249,9 @@ static string GenerateParameterString(Function f, out bool valid)
#endregion
- #region GenerateGenericParameterString
+ #region GenerateGenericTypeString
- static string GenerateGenericParameterString(Function f)
+ static string GenerateGenericTypeString(Function f)
{
var parameters = f.Parameters.Where(p => p.Generic);
if (parameters.Count() > 0)

0 comments on commit 5868972

Please sign in to comment.