2009-02-22 10:43:35 +00:00
|
|
|
|
#region --- License ---
|
|
|
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
|
|
|
* See license.txt for license info
|
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Runtime.InteropServices;
|
2009-08-17 12:28:22 +00:00
|
|
|
|
using System.Text;
|
2009-08-11 14:12:20 +00:00
|
|
|
|
using System.Xml.XPath;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
namespace Bind.Structures
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents a single parameter of an opengl function.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Parameter : Type
|
|
|
|
|
{
|
|
|
|
|
string cache;
|
|
|
|
|
bool rebuild;
|
|
|
|
|
bool unsafe_allowed; // True if the cache may contain unsafe types, false otherwise.
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a new Parameter without type and name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Parameter()
|
|
|
|
|
:base()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a new parameter from the parameters passed (deep copy).
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="p">The parameter to copy from.</param>
|
|
|
|
|
public Parameter(Parameter p)
|
|
|
|
|
: base(p)
|
|
|
|
|
{
|
|
|
|
|
if (p == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-08-25 15:59:57 +00:00
|
|
|
|
Name = p.Name;
|
|
|
|
|
Unchecked = p.Unchecked;
|
|
|
|
|
UnmanagedType = p.UnmanagedType;
|
|
|
|
|
Generic = p.Generic;
|
|
|
|
|
Flow = p.Flow;
|
|
|
|
|
cache = p.cache;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
//this.rebuild = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public string Name
|
|
|
|
|
|
|
|
|
|
string _name = String.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the name of the parameter.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return _name; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_name != value)
|
|
|
|
|
{
|
2009-07-15 22:33:26 +00:00
|
|
|
|
while (value.StartsWith("*"))
|
2009-06-30 08:39:35 +00:00
|
|
|
|
{
|
2009-07-15 22:33:26 +00:00
|
|
|
|
Pointer++;
|
|
|
|
|
value = value.Substring(1);
|
2009-06-30 08:39:35 +00:00
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
_name = value;
|
|
|
|
|
rebuild = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2009-03-08 19:19:52 +00:00
|
|
|
|
#region UnmanagedType
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
UnmanagedType _unmanaged_type;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the name of the parameter.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private UnmanagedType UnmanagedType
|
|
|
|
|
{
|
|
|
|
|
get { return _unmanaged_type; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_unmanaged_type != value)
|
|
|
|
|
{
|
|
|
|
|
_unmanaged_type = value;
|
|
|
|
|
rebuild = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public FlowDirection Flow
|
|
|
|
|
|
|
|
|
|
FlowDirection _flow;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the flow of the parameter.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public FlowDirection Flow
|
|
|
|
|
{
|
|
|
|
|
get { return _flow; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_flow != value)
|
|
|
|
|
{
|
|
|
|
|
_flow = value;
|
|
|
|
|
rebuild = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public bool NeedsPin
|
|
|
|
|
|
|
|
|
|
public bool NeedsPin
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (Array > 0 || Reference || CurrentType == "object") &&
|
|
|
|
|
!CurrentType.ToLower().Contains("string");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public bool Unchecked
|
|
|
|
|
|
|
|
|
|
private bool _unchecked;
|
|
|
|
|
|
|
|
|
|
public bool Unchecked
|
|
|
|
|
{
|
|
|
|
|
get { return _unchecked; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_unchecked != value)
|
|
|
|
|
{
|
|
|
|
|
_unchecked = value;
|
|
|
|
|
rebuild = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2009-03-21 21:44:07 +00:00
|
|
|
|
#region public bool Generic
|
|
|
|
|
|
|
|
|
|
bool generic;
|
|
|
|
|
public bool Generic
|
|
|
|
|
{
|
|
|
|
|
get { return generic; }
|
|
|
|
|
set { generic = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2009-02-22 10:43:35 +00:00
|
|
|
|
#region public override string CurrentType
|
|
|
|
|
|
|
|
|
|
public override string CurrentType
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return base.CurrentType;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
base.CurrentType = value;
|
|
|
|
|
rebuild = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2009-04-12 18:23:01 +00:00
|
|
|
|
#region public bool DiffersOnlyOnReference
|
|
|
|
|
|
|
|
|
|
// Returns true if this parameter differs only on reference compared to another parameter, i.e:
|
|
|
|
|
// returns true for 'int' & 'ref int'
|
|
|
|
|
// returns true for 'ref float' & 'float'
|
|
|
|
|
// returns false 'int' & 'int*'
|
|
|
|
|
// returns false 'int' & 'int[]'
|
|
|
|
|
// returns false 'int' & 'float'
|
|
|
|
|
public bool DiffersOnlyOnReference(Parameter other)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
CurrentType == other.CurrentType &&
|
2009-07-15 22:33:26 +00:00
|
|
|
|
(Reference && !(other.Reference || other.Array > 0 || other.Pointer != 0) ||
|
|
|
|
|
other.Reference && !(Reference || Array > 0 || Pointer != 0));
|
2009-04-12 18:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2009-03-08 19:19:52 +00:00
|
|
|
|
#region public override string ToString()
|
|
|
|
|
|
2009-02-22 10:43:35 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return ToString(false);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-08 19:19:52 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2009-02-22 10:43:35 +00:00
|
|
|
|
#region public string ToString(bool override_unsafe_setting)
|
|
|
|
|
|
|
|
|
|
public string ToString(bool override_unsafe_setting)
|
|
|
|
|
{
|
|
|
|
|
rebuild |= unsafe_allowed |= override_unsafe_setting;
|
|
|
|
|
unsafe_allowed = override_unsafe_setting;
|
|
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(cache) && !rebuild)
|
|
|
|
|
{
|
|
|
|
|
return cache;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
if (Flow == FlowDirection.Out)
|
2009-08-12 10:11:41 +00:00
|
|
|
|
sb.Append("[OutAttribute] ");
|
2009-02-22 10:43:35 +00:00
|
|
|
|
else if (Flow == FlowDirection.Undefined)
|
2009-08-12 10:11:41 +00:00
|
|
|
|
sb.Append("[InAttribute, OutAttribute] ");
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
if (Reference)
|
|
|
|
|
{
|
|
|
|
|
if (Flow == FlowDirection.Out)
|
|
|
|
|
sb.Append("out ");
|
|
|
|
|
else
|
|
|
|
|
sb.Append("ref ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!override_unsafe_setting && ((Settings.Compatibility & Settings.Legacy.NoPublicUnsafeFunctions) != Settings.Legacy.None))
|
|
|
|
|
{
|
2009-07-15 22:33:26 +00:00
|
|
|
|
if (Pointer != 0)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
|
|
|
|
sb.Append("IntPtr");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append(CurrentType);
|
|
|
|
|
if (Array > 0)
|
2009-03-21 21:44:07 +00:00
|
|
|
|
{
|
|
|
|
|
sb.Append("[");
|
|
|
|
|
for (int i = 1; i < Array; i++)
|
|
|
|
|
sb.Append(",");
|
|
|
|
|
sb.Append("]");
|
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append(CurrentType);
|
2009-07-15 22:33:26 +00:00
|
|
|
|
for (int i = 0; i < Pointer; i++)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
sb.Append("*");
|
|
|
|
|
if (Array > 0)
|
2009-03-21 21:44:07 +00:00
|
|
|
|
{
|
|
|
|
|
sb.Append("[");
|
|
|
|
|
for (int i = 1; i < Array; i++)
|
|
|
|
|
sb.Append(",");
|
|
|
|
|
sb.Append("]");
|
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
if (!String.IsNullOrEmpty(Name))
|
|
|
|
|
{
|
|
|
|
|
sb.Append(" ");
|
|
|
|
|
sb.Append(Utilities.Keywords.Contains(Name) ? "@" + Name : Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rebuild = false;
|
|
|
|
|
cache = sb.ToString();
|
|
|
|
|
return cache;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2009-08-11 14:12:20 +00:00
|
|
|
|
#region override public void Translate(XPathNavigator overrides, string category)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
2009-08-11 14:12:20 +00:00
|
|
|
|
override public void Translate(XPathNavigator overrides, string category)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
2009-08-11 14:12:20 +00:00
|
|
|
|
base.Translate(overrides, category);
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
// Find out the necessary wrapper types.
|
2009-07-15 22:33:26 +00:00
|
|
|
|
if (Pointer != 0)/* || CurrentType == "IntPtr")*/
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
2009-07-15 22:33:26 +00:00
|
|
|
|
if (CurrentType.ToLower().Contains("string"))
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
2009-07-15 22:33:26 +00:00
|
|
|
|
// string* -> [In] String[] or [Out] StringBuilder[]
|
2009-02-22 10:43:35 +00:00
|
|
|
|
CurrentType =
|
2009-07-15 22:33:26 +00:00
|
|
|
|
Flow == FlowDirection.Out ?
|
|
|
|
|
"System.Text.StringBuilder[]" :
|
|
|
|
|
"String[]";
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
2009-07-15 22:33:26 +00:00
|
|
|
|
Pointer = 0;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
WrapperType = WrapperTypes.None;
|
|
|
|
|
}
|
2009-07-15 22:33:26 +00:00
|
|
|
|
else if (CurrentType.ToLower().Contains("char"))
|
2009-06-29 18:32:51 +00:00
|
|
|
|
{
|
2009-07-15 22:33:26 +00:00
|
|
|
|
// char* -> [In] String or [Out] StringBuilder
|
2009-06-29 18:32:51 +00:00
|
|
|
|
CurrentType =
|
2009-07-15 22:33:26 +00:00
|
|
|
|
Flow == FlowDirection.Out ?
|
|
|
|
|
"System.Text.StringBuilder" :
|
|
|
|
|
"String";
|
2009-06-29 18:32:51 +00:00
|
|
|
|
|
2009-07-15 22:33:26 +00:00
|
|
|
|
Pointer = 0;
|
2009-06-29 18:32:51 +00:00
|
|
|
|
WrapperType = WrapperTypes.None;
|
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
else if (CurrentType.ToLower().Contains("void") ||
|
2009-04-15 13:14:41 +00:00
|
|
|
|
(!String.IsNullOrEmpty(PreviousType) && PreviousType.ToLower().Contains("void"))) /*|| CurrentType.Contains("IntPtr"))*/
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
|
|
|
|
CurrentType = "IntPtr";
|
2009-07-15 22:33:26 +00:00
|
|
|
|
Pointer = 0;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
WrapperType = WrapperTypes.GenericParameter;
|
|
|
|
|
}
|
2009-04-15 13:14:41 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
WrapperType = WrapperTypes.ArrayParameter;
|
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Reference)
|
|
|
|
|
WrapperType |= WrapperTypes.ReferenceParameter;
|
|
|
|
|
|
2009-06-30 08:39:35 +00:00
|
|
|
|
if (Name == "params")
|
|
|
|
|
Name = "@params";
|
2009-08-09 17:47:15 +00:00
|
|
|
|
if (Name == "event")
|
|
|
|
|
Name = "@event";
|
2009-06-30 08:39:35 +00:00
|
|
|
|
|
2009-02-22 10:43:35 +00:00
|
|
|
|
// This causes problems with bool arrays
|
|
|
|
|
//if (CurrentType.ToLower().Contains("bool"))
|
|
|
|
|
// WrapperType = WrapperTypes.BoolParameter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2009-07-15 22:33:26 +00:00
|
|
|
|
|
|
|
|
|
#region Static Members
|
|
|
|
|
|
|
|
|
|
// Returns the FlowDirection that matches the specified string
|
|
|
|
|
// ("out" or "in", otherwise undefined).
|
|
|
|
|
public static FlowDirection GetFlowDirection(string direction)
|
|
|
|
|
{
|
|
|
|
|
return direction == "out" ? FlowDirection.Out : direction == "in" ? FlowDirection.In : FlowDirection.Undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Holds the parameter list of an opengl function.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ParameterCollection : List<Parameter>
|
|
|
|
|
{
|
|
|
|
|
string cache = String.Empty;
|
|
|
|
|
string callStringCache = String.Empty;
|
|
|
|
|
private bool rebuild = true;
|
|
|
|
|
bool hasPointerParameters;
|
|
|
|
|
bool hasReferenceParameters;
|
2009-03-08 19:19:52 +00:00
|
|
|
|
bool hasUnsignedParameters;
|
2009-03-21 21:44:07 +00:00
|
|
|
|
bool hasGenericParameters;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
bool unsafe_types_allowed;
|
|
|
|
|
public bool Rebuild
|
|
|
|
|
{
|
|
|
|
|
private get { return rebuild; }
|
|
|
|
|
set { rebuild = true;/*value;*/ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
public ParameterCollection()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ParameterCollection(ParameterCollection pc)
|
|
|
|
|
{
|
|
|
|
|
foreach (Parameter p in pc)
|
|
|
|
|
{
|
2009-08-25 15:59:57 +00:00
|
|
|
|
Add(new Parameter(p));
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region void BuildCache()
|
|
|
|
|
|
|
|
|
|
void BuildCache()
|
|
|
|
|
{
|
2009-03-21 21:44:07 +00:00
|
|
|
|
BuildReferenceAndPointerParametersCache();
|
2009-02-22 10:43:35 +00:00
|
|
|
|
BuildCallStringCache();
|
|
|
|
|
BuildToStringCache(unsafe_types_allowed);
|
|
|
|
|
Rebuild = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public bool HasPointerParameters
|
|
|
|
|
|
|
|
|
|
public bool HasPointerParameters
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2009-03-08 19:19:52 +00:00
|
|
|
|
if (Rebuild)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
BuildCache();
|
2009-03-08 19:19:52 +00:00
|
|
|
|
|
|
|
|
|
return hasPointerParameters;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public bool HasReferenceParameters
|
|
|
|
|
|
|
|
|
|
public bool HasReferenceParameters
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2009-03-08 19:19:52 +00:00
|
|
|
|
if (Rebuild)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
BuildCache();
|
2009-03-08 19:19:52 +00:00
|
|
|
|
|
|
|
|
|
return hasReferenceParameters;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public bool HasUnsignedParameters
|
|
|
|
|
|
|
|
|
|
public bool HasUnsignedParameters
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (Rebuild)
|
|
|
|
|
BuildCache();
|
|
|
|
|
|
|
|
|
|
return hasUnsignedParameters;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2009-03-21 21:44:07 +00:00
|
|
|
|
#region public bool HasGenericParameters
|
|
|
|
|
|
|
|
|
|
public bool HasGenericParameters
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (Rebuild)
|
|
|
|
|
BuildCache();
|
|
|
|
|
|
|
|
|
|
return hasGenericParameters;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2009-02-22 10:43:35 +00:00
|
|
|
|
#region void BuildReferenceAndPointerParametersCache()
|
|
|
|
|
|
|
|
|
|
void BuildReferenceAndPointerParametersCache()
|
|
|
|
|
{
|
|
|
|
|
foreach (Parameter p in this)
|
|
|
|
|
{
|
2009-07-15 22:33:26 +00:00
|
|
|
|
if (p.Pointer != 0 || p.CurrentType.Contains("IntPtr"))
|
2009-02-22 10:43:35 +00:00
|
|
|
|
hasPointerParameters = true;
|
|
|
|
|
|
|
|
|
|
if (p.Reference)
|
|
|
|
|
hasReferenceParameters = true;
|
2009-03-08 19:19:52 +00:00
|
|
|
|
|
|
|
|
|
if (p.Unsigned)
|
|
|
|
|
hasUnsignedParameters = true;
|
2009-03-21 21:44:07 +00:00
|
|
|
|
|
|
|
|
|
if (p.Generic)
|
|
|
|
|
hasGenericParameters = true;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region new public void Add(Parameter p)
|
|
|
|
|
|
|
|
|
|
new public void Add(Parameter p)
|
|
|
|
|
{
|
|
|
|
|
Rebuild = true;
|
|
|
|
|
base.Add(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return ToString(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region public string ToString(bool override_unsafe_setting)
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the parameter declaration string.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="override_unsafe_setting">
|
|
|
|
|
/// If true, unsafe types will be used even if the Settings.Compatibility.NoPublicUnsafeFunctions flag is set.
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <returns>The parameter list of an opengl function in the form ( [parameters] )</returns>
|
|
|
|
|
public string ToString(bool override_unsafe_setting)
|
|
|
|
|
{
|
|
|
|
|
Rebuild |= unsafe_types_allowed != override_unsafe_setting;
|
|
|
|
|
unsafe_types_allowed = override_unsafe_setting;
|
|
|
|
|
|
|
|
|
|
if (!Rebuild)
|
|
|
|
|
{
|
|
|
|
|
return cache;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BuildCache();
|
|
|
|
|
return cache;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region void BuildToStringCache(bool override_unsafe_setting)
|
|
|
|
|
|
|
|
|
|
void BuildToStringCache(bool override_unsafe_setting)
|
|
|
|
|
{
|
|
|
|
|
unsafe_types_allowed = override_unsafe_setting;
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("(");
|
2009-08-25 15:59:57 +00:00
|
|
|
|
if (Count > 0)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
|
|
|
|
foreach (Parameter p in this)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(p.ToString(override_unsafe_setting));
|
|
|
|
|
sb.Append(", ");
|
|
|
|
|
}
|
|
|
|
|
sb.Replace(", ", ")", sb.Length - 2, 2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
sb.Append(")");
|
|
|
|
|
|
|
|
|
|
cache = sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region public string CallString()
|
|
|
|
|
|
|
|
|
|
public string CallString()
|
|
|
|
|
{
|
|
|
|
|
if (!Rebuild)
|
|
|
|
|
{
|
|
|
|
|
return callStringCache;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BuildCache();
|
|
|
|
|
return callStringCache;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region private void BuildCallStringCache()
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Builds a call string instance and caches it.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BuildCallStringCache()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
sb.Append("(");
|
|
|
|
|
|
2009-08-25 15:59:57 +00:00
|
|
|
|
if (Count > 0)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
|
|
|
|
foreach (Parameter p in this)
|
|
|
|
|
{
|
|
|
|
|
if (p.Unchecked)
|
|
|
|
|
sb.Append("unchecked((" + p.CurrentType + ")");
|
|
|
|
|
|
2009-03-21 21:44:07 +00:00
|
|
|
|
if (!p.Generic && p.CurrentType != "object")
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
|
|
|
|
if (p.CurrentType.ToLower().Contains("string"))
|
|
|
|
|
{
|
|
|
|
|
sb.Append(String.Format("({0}{1})",
|
|
|
|
|
p.CurrentType, (p.Array > 0) ? "[]" : ""));
|
|
|
|
|
}
|
2009-08-11 14:12:20 +00:00
|
|
|
|
else if (p.IndirectionLevel != 0)
|
2009-02-22 10:43:35 +00:00
|
|
|
|
{
|
|
|
|
|
if (((Settings.Compatibility & Settings.Legacy.TurnVoidPointersToIntPtr) != Settings.Legacy.None) &&
|
2009-07-15 22:33:26 +00:00
|
|
|
|
p.Pointer != 0 && p.CurrentType.Contains("void"))
|
2009-02-22 10:43:35 +00:00
|
|
|
|
sb.Append("(IntPtr)");
|
2009-08-11 14:12:20 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append("(");
|
|
|
|
|
sb.Append(p.CurrentType);
|
|
|
|
|
for (int i = 0; i < p.IndirectionLevel; i++)
|
|
|
|
|
sb.Append("*");
|
|
|
|
|
sb.Append(")");
|
|
|
|
|
}
|
2009-02-22 10:43:35 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append(String.Format("({0})", p.CurrentType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-21 21:44:07 +00:00
|
|
|
|
sb.Append(Utilities.Keywords.Contains(p.Name) ? "@" + p.Name : p.Name);
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
|
|
if (p.Unchecked)
|
|
|
|
|
sb.Append(")");
|
|
|
|
|
|
|
|
|
|
sb.Append(", ");
|
|
|
|
|
}
|
|
|
|
|
sb.Replace(", ", ")", sb.Length - 2, 2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append(")");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callStringCache = sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public bool ContainsType(string type)
|
|
|
|
|
{
|
|
|
|
|
foreach (Parameter p in this)
|
|
|
|
|
if (p.CurrentType == type)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|