Fixed issue http://www.opentk.com/node/794 (suppress array overloads for functions that receive/return pointers to single elements).

This commit is contained in:
the_fiddler 2009-04-15 13:14:41 +00:00
parent 75db59c202
commit 0ecdd1c9e3
5 changed files with 558 additions and 4697 deletions

View file

@ -146,6 +146,8 @@ namespace Bind.GL2
p.Name = Utilities.Keywords.Contains(words[1]) ? "@" + words[1] : words[1];
p.CurrentType = words[2];
p.Pointer = words[4].Contains("array") ? true : words[4].Contains("reference") ? true : false;
if (p.Pointer && words[5].Contains("[1]"))
p.ElementCount = 1;
p.Flow = words[3] == "in" ? Parameter.FlowDirection.In : Parameter.FlowDirection.Out;
d.Parameters.Add(p);
@ -312,7 +314,6 @@ namespace Bind.GL2
else
{
// The enum already exists, merge constants.
Trace.WriteLine(String.Format("Enum {0} already defined, merging constants.", e.Name));
foreach (Constant t in e.ConstantCollection.Values)
Utilities.Merge(enums[e.Name], t);
}

View file

@ -257,7 +257,7 @@ namespace Bind.Structures
// Array overloads
foreach (Parameter p in this.Parameters)
{
if (p.WrapperType == WrapperTypes.ArrayParameter)
if (p.WrapperType == WrapperTypes.ArrayParameter && p.ElementCount != 1)
{
p.Reference = false;
p.Array = 1;
@ -325,7 +325,7 @@ namespace Bind.Structures
WrapVoidPointers(wrappers);
--index;
// On stack rewind, create object wrappers
// On stack rewind, create generic wrappers
Parameters[index].Reference = true;
Parameters[index].Array = 0;
Parameters[index].Pointer = false;

View file

@ -295,8 +295,6 @@ namespace Bind.Structures
// Find out the necessary wrapper types.
if (Pointer)/* || CurrentType == "IntPtr")*/
{
WrapperType = WrapperTypes.ArrayParameter;
if (CurrentType.ToLower().Contains("char") || CurrentType.ToLower().Contains("string"))
{
// char* or string -> [In] String or [Out] StringBuilder
@ -309,12 +307,16 @@ namespace Bind.Structures
WrapperType = WrapperTypes.None;
}
else if (CurrentType.ToLower().Contains("void") ||
(!String.IsNullOrEmpty(PreviousType) && PreviousType.ToLower().Contains("void"))) /*|| CurrentType.Contains("IntPtr"))*/
(!String.IsNullOrEmpty(PreviousType) && PreviousType.ToLower().Contains("void"))) /*|| CurrentType.Contains("IntPtr"))*/
{
CurrentType = "IntPtr";
Pointer = false;
WrapperType = WrapperTypes.GenericParameter;
}
else
{
WrapperType = WrapperTypes.ArrayParameter;
}
}
if (Reference)

View file

@ -60,6 +60,7 @@ namespace Bind.Structures
this.Array = t.Array;
this.Pointer = t.Pointer;
this.Reference = t.Reference;
this.ElementCount = t.ElementCount;
}
}
@ -137,6 +138,19 @@ namespace Bind.Structures
#endregion
#region public int ElementCount
int element_count;
// If the type is an array and ElementCount > 0, then ElemenCount defines the expected array length.
public int ElementCount
{
get { return element_count; }
set { element_count = value > 0 ? value : 0; }
}
#endregion
#region public bool Pointer
bool pointer;

File diff suppressed because it is too large Load diff