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.Name = Utilities.Keywords.Contains(words[1]) ? "@" + words[1] : words[1];
p.CurrentType = words[2]; p.CurrentType = words[2];
p.Pointer = words[4].Contains("array") ? true : words[4].Contains("reference") ? true : false; 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; p.Flow = words[3] == "in" ? Parameter.FlowDirection.In : Parameter.FlowDirection.Out;
d.Parameters.Add(p); d.Parameters.Add(p);
@ -312,7 +314,6 @@ namespace Bind.GL2
else else
{ {
// The enum already exists, merge constants. // 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) foreach (Constant t in e.ConstantCollection.Values)
Utilities.Merge(enums[e.Name], t); Utilities.Merge(enums[e.Name], t);
} }

View file

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

View file

@ -295,8 +295,6 @@ namespace Bind.Structures
// Find out the necessary wrapper types. // Find out the necessary wrapper types.
if (Pointer)/* || CurrentType == "IntPtr")*/ if (Pointer)/* || CurrentType == "IntPtr")*/
{ {
WrapperType = WrapperTypes.ArrayParameter;
if (CurrentType.ToLower().Contains("char") || CurrentType.ToLower().Contains("string")) if (CurrentType.ToLower().Contains("char") || CurrentType.ToLower().Contains("string"))
{ {
// char* or string -> [In] String or [Out] StringBuilder // char* or string -> [In] String or [Out] StringBuilder
@ -315,6 +313,10 @@ namespace Bind.Structures
Pointer = false; Pointer = false;
WrapperType = WrapperTypes.GenericParameter; WrapperType = WrapperTypes.GenericParameter;
} }
else
{
WrapperType = WrapperTypes.ArrayParameter;
}
} }
if (Reference) if (Reference)

View file

@ -60,6 +60,7 @@ namespace Bind.Structures
this.Array = t.Array; this.Array = t.Array;
this.Pointer = t.Pointer; this.Pointer = t.Pointer;
this.Reference = t.Reference; this.Reference = t.Reference;
this.ElementCount = t.ElementCount;
} }
} }
@ -137,6 +138,19 @@ namespace Bind.Structures
#endregion #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 #region public bool Pointer
bool pointer; bool pointer;

File diff suppressed because it is too large Load diff