From 6c86f654ed968cfca0c5c81ae12e1ae1b7b3ca86 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sat, 10 Nov 2007 10:28:22 +0000 Subject: [PATCH] Fixed IntPtr processing - real pointers (with object overloads) are now differentiated from plain IntPtr parameters (e.g. offsets). Fixed Tao bindings generation. --- Source/Bind/Structures/Delegate.cs | 4 ++-- Source/Bind/Structures/Function.cs | 21 +++++++++++++++------ Source/Bind/Structures/Parameter.cs | 6 ++++-- Source/Bind/Structures/Type.cs | 11 +++++++++-- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Source/Bind/Structures/Delegate.cs b/Source/Bind/Structures/Delegate.cs index 7ec8d132..af96b4d1 100644 --- a/Source/Bind/Structures/Delegate.cs +++ b/Source/Bind/Structures/Delegate.cs @@ -76,7 +76,7 @@ namespace Bind.Structures /// /// Gets the CLSCompliant property. True if the delegate is not CLSCompliant. /// - public bool CLSCompliant + public virtual bool CLSCompliant { get { @@ -341,7 +341,7 @@ namespace Bind.Structures public void CreateWrappers() { - if (this.Name.Contains("GetBoolean")) + if (this.Name.Contains("ReadPixels")) { } diff --git a/Source/Bind/Structures/Function.cs b/Source/Bind/Structures/Function.cs index ae1c6496..779fcc1e 100644 --- a/Source/Bind/Structures/Function.cs +++ b/Source/Bind/Structures/Function.cs @@ -81,8 +81,8 @@ namespace Bind.Structures { get { - //if ((Settings.Compatibility & Settings.Legacy.NoPublicUnsafeFunctions) != Settings.Legacy.None) - // return false; + if ((Settings.Compatibility & Settings.Legacy.NoPublicUnsafeFunctions) != Settings.Legacy.None) + return false; return base.Unsafe; } @@ -526,18 +526,20 @@ namespace Bind.Structures } } - //if (!f.Unsafe && (fixed_statements.Count > 0 || fixed_statements.Count > 0)) - if (fixed_statements.Count > 0) + if (!f.Unsafe || fixed_statements.Count > 0) { f.Body.Add("unsafe"); f.Body.Add("{"); f.Body.Indent(); + } + if (fixed_statements.Count > 0) + { f.Body.AddRange(fixed_statements); f.Body.Add("{"); f.Body.Indent(); } - + if (handle_statements.Count > 0) { f.Body.AddRange(handle_statements); @@ -594,11 +596,14 @@ namespace Bind.Structures f.Body.Add("}"); } - if (fixed_statements.Count > 0) + if (!f.Unsafe || fixed_statements.Count > 0) { f.Body.Unindent(); f.Body.Add("}"); + } + if (fixed_statements.Count > 0) + { f.Body.Unindent(); f.Body.Add("}"); } @@ -705,6 +710,10 @@ namespace Bind.Structures /// The Function to add. public void AddChecked(Function f) { + if (f.Name.Contains("Bitmap")) + { + } + if (Bind.Structures.Function.Wrappers.ContainsKey(f.Extension)) { int index = Bind.Structures.Function.Wrappers[f.Extension].IndexOf(f); diff --git a/Source/Bind/Structures/Parameter.cs b/Source/Bind/Structures/Parameter.cs index 00e0e0af..27550624 100644 --- a/Source/Bind/Structures/Parameter.cs +++ b/Source/Bind/Structures/Parameter.cs @@ -264,7 +264,7 @@ namespace Bind.Structures Pointer = false; WrapperType = WrapperTypes.None; } - else if (CurrentType.ToLower().Contains("void")) /*|| CurrentType.Contains("IntPtr"))*/ + else if (CurrentType.ToLower().Contains("void") || PreviousType.ToLower().Contains("void")) /*|| CurrentType.Contains("IntPtr"))*/ { CurrentType = "IntPtr"; Pointer = false; @@ -407,7 +407,9 @@ namespace Bind.Structures /// /// Gets the parameter declaration string. /// - /// If true, unsafe types will be used even if the Settings.Compatibility.NoPublicUnsafeFunctions flag is set. + /// + /// If true, unsafe types will be used even if the Settings.Compatibility.NoPublicUnsafeFunctions flag is set. + /// /// The parameter list of an opengl function in the form ( [parameters] ) public string ToString(bool override_unsafe_setting) { diff --git a/Source/Bind/Structures/Type.cs b/Source/Bind/Structures/Type.cs index 453c7258..ae2531be 100644 --- a/Source/Bind/Structures/Type.cs +++ b/Source/Bind/Structures/Type.cs @@ -156,7 +156,14 @@ namespace Bind.Structures get { bool compliant = !(CurrentType.Contains("UInt") || CurrentType.Contains("SByte")); - return compliant && (!Pointer || CurrentType.Contains("IntPtr")); + if (Pointer) + { + compliant &= CurrentType.Contains("IntPtr"); // IntPtr's are CLSCompliant. + // If the NoPublicUnsageFunctions is set, the pointer will be CLSCompliant. + compliant |= (Settings.Compatibility & Settings.Legacy.NoPublicUnsafeFunctions) != Settings.Legacy.None; + } + return compliant; + //return compliant && (!Pointer || CurrentType.Contains("IntPtr")); //return compliant && !(Pointer && ((Settings.Compatibility & Settings.Legacy.NoPublicUnsafeFunctions) == Settings.Legacy.None)); /* @@ -334,7 +341,7 @@ namespace Bind.Structures Bind.Structures.Type.CSTypes.ContainsKey(CurrentType) ? Bind.Structures.Type.CSTypes[CurrentType] : CurrentType; - if (CurrentType == "IntPtr") + if (CurrentType == "IntPtr" && String.IsNullOrEmpty(PreviousType)) Pointer = false; } }