From 58faedc0fd24595608148ae4db13665cd1888494 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 12 Apr 2009 18:23:01 +0000 Subject: [PATCH] Generator now trims 'v' suffixes from all functions and marks resulting non cls-compliant overloads as such. Bumped version number. --- Source/Bind/GL2/Generator.cs | 6 +-- Source/Bind/Properties/AssemblyInfo.cs | 4 +- Source/Bind/Structures/Delegate.cs | 57 +++++++++++++++++++++++++- Source/Bind/Structures/Parameter.cs | 18 ++++++++ 4 files changed, 78 insertions(+), 7 deletions(-) diff --git a/Source/Bind/GL2/Generator.cs b/Source/Bind/GL2/Generator.cs index 1b57921c..2630630a 100644 --- a/Source/Bind/GL2/Generator.cs +++ b/Source/Bind/GL2/Generator.cs @@ -64,9 +64,9 @@ namespace Bind.GL2 { // Matches functions that cannot have their trailing 'v' trimmed for CLS-Compliance reasons. // Built through trial and error :) - Function.endingsAddV = - new Regex(@"(Coord1|Attrib(I?)1(u?)|Stream1|Uniform2(u?)|(Point|Convolution|Transform|Sprite|List|Combiner|Tex)Parameter|Fog(Coord)?.*|VertexWeight|(Fragment)?Light(Model)?|Material|ReplacementCodeu?b?|Tex(Gen|Env)|Indexu?|TextureParameter.v)", - RegexOptions.Compiled); + //Function.endingsAddV = + // new Regex(@"(Coord1|Attrib(I?)1(u?)|Stream1|Uniform2(u?)|(Point|Convolution|Transform|Sprite|List|Combiner|Tex)Parameter|Fog(Coord)?.*|VertexWeight|(Fragment)?Light(Model)?|Material|ReplacementCodeu?b?|Tex(Gen|Env)|Indexu?|TextureParameter.v)", + // RegexOptions.Compiled); Bind.Structures.Type.Initialize(glTypemap, csTypemap); Bind.Structures.Enum.Initialize(enumSpec, enumSpecExt); diff --git a/Source/Bind/Properties/AssemblyInfo.cs b/Source/Bind/Properties/AssemblyInfo.cs index 86cf4691..23acfd85 100644 --- a/Source/Bind/Properties/AssemblyInfo.cs +++ b/Source/Bind/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("0.9.9.8")] -[assembly: AssemblyFileVersion("0.9.9.8")] +[assembly: AssemblyVersion("0.9.9.9")] +[assembly: AssemblyFileVersion("0.9.9.9")] diff --git a/Source/Bind/Structures/Delegate.cs b/Source/Bind/Structures/Delegate.cs index 3f92f3fb..aadccd0f 100644 --- a/Source/Bind/Structures/Delegate.cs +++ b/Source/Bind/Structures/Delegate.cs @@ -22,6 +22,7 @@ namespace Bind.Structures internal static DelegateCollection Delegates; private static bool delegatesLoaded; + bool? cls_compliance_overriden; #region internal static void Initialize(string glSpec, string glSpecExt) @@ -44,6 +45,8 @@ namespace Bind.Structures } } } + Console.WriteLine("Marking CLS compliance for wrappers."); + MarkCLSCompliance(Function.Wrappers); delegatesLoaded = true; } } @@ -80,6 +83,9 @@ namespace Bind.Structures { get { + if (cls_compliance_overriden != null) + return (bool)cls_compliance_overriden; + if (Unsafe) return false; @@ -93,6 +99,10 @@ namespace Bind.Structures } return true; } + set + { + cls_compliance_overriden = value; + } } #endregion @@ -341,9 +351,52 @@ namespace Bind.Structures #region --- Wrapper Creation --- - #region public IEnumerable CreateWrappers() + #region MarkCLSCompliance - public void CreateWrappers() + static void MarkCLSCompliance(FunctionCollection collection) + { + foreach (List wrappers in Function.Wrappers.Values) + { + for (int i = 0; i < wrappers.Count; i++) + { + for (int j = i + 1; j < wrappers.Count; j++) + { + if (wrappers[i].TrimmedName == wrappers[j].TrimmedName && wrappers[i].Parameters.Count == wrappers[j].Parameters.Count) + { + bool function_i_is_problematic = false; + bool function_j_is_problematic = false; + + int k; + for (k = 0; k < wrappers[i].Parameters.Count; k++) + { + if (wrappers[i].Parameters[k].CurrentType != wrappers[j].Parameters[k].CurrentType) + break; + + if (wrappers[i].Parameters[k].DiffersOnlyOnReference(wrappers[j].Parameters[k])) + if (wrappers[i].Parameters[k].Reference) + function_i_is_problematic = true; + else + function_j_is_problematic = true; + } + + if (k == wrappers[i].Parameters.Count) + { + if (function_i_is_problematic) + wrappers[i].CLSCompliant = false; + if (function_j_is_problematic) + wrappers[j].CLSCompliant = false; + } + } + } + } + } + } + + #endregion + + #region CreateWrappers + + void CreateWrappers() { List wrappers = new List(); if (!NeedsWrapper) diff --git a/Source/Bind/Structures/Parameter.cs b/Source/Bind/Structures/Parameter.cs index f50bf1c5..f920efe5 100644 --- a/Source/Bind/Structures/Parameter.cs +++ b/Source/Bind/Structures/Parameter.cs @@ -186,6 +186,24 @@ namespace Bind.Structures #endregion + #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 && + (Reference && !(other.Reference || other.Array > 0 || other.Pointer) || + other.Reference && !(Reference || Array > 0 || Pointer)); + } + + #endregion + #region public override string ToString() public override string ToString()