Merge pull request #588 from Frassle/issue517
Change StringBuilder parameters to out Strings
This commit is contained in:
commit
876b234872
22 changed files with 22548 additions and 22370 deletions
|
@ -695,13 +695,45 @@ namespace Bind
|
|||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<string> attributes = new List<string>();
|
||||
if (p.Flow == FlowDirection.Out)
|
||||
{
|
||||
sb.Append("[OutAttribute] ");
|
||||
attributes.Add("OutAttribute");
|
||||
}
|
||||
else if (p.Flow == FlowDirection.Undefined)
|
||||
{
|
||||
sb.Append("[InAttribute, OutAttribute] ");
|
||||
attributes.Add("InAttribute");
|
||||
attributes.Add("OutAttribute");
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(p.ComputeSize))
|
||||
{
|
||||
int count;
|
||||
if(Int32.TryParse(p.ComputeSize, out count))
|
||||
{
|
||||
attributes.Add(String.Format("CountAttribute(Count = {0})", count));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p.ComputeSize.StartsWith("COMPSIZE"))
|
||||
{
|
||||
//remove the compsize hint, just keep comma delimited param names
|
||||
var len = "COMPSIZE(".Length;
|
||||
var computed = p.ComputeSize.Substring(len, (p.ComputeSize.Length - len) - 1);
|
||||
attributes.Add(String.Format("CountAttribute(Computed = \"{0}\")", computed));
|
||||
}
|
||||
else
|
||||
{
|
||||
attributes.Add(String.Format("CountAttribute(Parameter = \"{0}\")", p.ComputeSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(attributes.Count != 0)
|
||||
{
|
||||
sb.Append("[");
|
||||
sb.Append(string.Join(", ", attributes));
|
||||
sb.Append("] ");
|
||||
}
|
||||
|
||||
if (p.Reference)
|
||||
|
|
|
@ -358,7 +358,7 @@ namespace Bind
|
|||
}
|
||||
else if (enum_override.Value == "StringBuilder")
|
||||
{
|
||||
type.QualifiedType = "StringBuilder";
|
||||
throw new NotSupportedException("StringBuilder enum overrides are no longer supported");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1237,13 +1237,10 @@ namespace Bind
|
|||
var p = wrapper.Parameters[i];
|
||||
if ((p.WrapperType & WrapperTypes.StringParameter) != 0)
|
||||
{
|
||||
p.QualifiedType = "String";
|
||||
if (p.Flow == FlowDirection.Out)
|
||||
{
|
||||
p.QualifiedType = "StringBuilder";
|
||||
}
|
||||
else
|
||||
{
|
||||
p.QualifiedType = "String";
|
||||
p.Reference = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>
|
||||
</AppDesignerFolder>
|
||||
|
|
|
@ -319,13 +319,6 @@ namespace Bind
|
|||
}
|
||||
|
||||
p.ComputeSize = param.GetAttribute("count", String.Empty).Trim();
|
||||
if (p.ComputeSize.StartsWith("COMPSIZE"))
|
||||
{
|
||||
//remove the compsize hint, just keep comma delimited param names
|
||||
var len = "COMPSIZE(".Length;
|
||||
p.ComputeSize = p.ComputeSize.Substring(len, (p.ComputeSize.Length - len) - 1);
|
||||
}
|
||||
|
||||
p.Flow = Parameter.GetFlowDirection(param.GetAttribute("flow", String.Empty).Trim());
|
||||
|
||||
d.Parameters.Add(p);
|
||||
|
|
10
src/Generator.Rewrite/CountAttribute.cs
Normal file
10
src/Generator.Rewrite/CountAttribute.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
namespace OpenTK.Rewrite
|
||||
{
|
||||
internal class CountAttribute
|
||||
{
|
||||
public int Count;
|
||||
public string Parameter;
|
||||
public string Computed;
|
||||
}
|
||||
}
|
|
@ -53,6 +53,7 @@
|
|||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CountAttribute.cs" />
|
||||
<Compile Include="GeneratedVariableIdentifier.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
@ -51,7 +51,6 @@ namespace OpenTK.Rewrite
|
|||
private static AssemblyDefinition mscorlib;
|
||||
|
||||
private static TypeDefinition TypeMarshal;
|
||||
private static TypeDefinition TypeStringBuilder;
|
||||
private static TypeDefinition TypeVoid;
|
||||
private static TypeDefinition TypeIntPtr;
|
||||
private static TypeDefinition TypeInt32;
|
||||
|
@ -123,7 +122,6 @@ namespace OpenTK.Rewrite
|
|||
return;
|
||||
}
|
||||
TypeMarshal = mscorlib.MainModule.GetType("System.Runtime.InteropServices.Marshal");
|
||||
TypeStringBuilder = mscorlib.MainModule.GetType("System.Text.StringBuilder");
|
||||
TypeVoid = mscorlib.MainModule.GetType("System.Void");
|
||||
TypeIntPtr = mscorlib.MainModule.GetType("System.IntPtr");
|
||||
TypeInt32 = mscorlib.MainModule.GetType("System.Int32");
|
||||
|
@ -256,6 +254,19 @@ namespace OpenTK.Rewrite
|
|||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var parameter in method.Parameters)
|
||||
{
|
||||
var pattr = parameter.CustomAttributes;
|
||||
for (int i = 0; i < pattr.Count; i++)
|
||||
{
|
||||
if (pattr[i].AttributeType.Name == "CountAttribute")
|
||||
{
|
||||
pattr.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -534,9 +545,9 @@ namespace OpenTK.Rewrite
|
|||
{
|
||||
foreach (var p in wrapper.Parameters)
|
||||
{
|
||||
if (p.ParameterType.Name == "StringBuilder")
|
||||
if (!p.ParameterType.IsArray && p.ParameterType.Name == "String" && p.IsOut)
|
||||
{
|
||||
EmitStringBuilderEpilogue(wrapper, native, p, body, il, GetGeneratedVariable(generatedVariables, p.Name + "_sb_ptr", body));
|
||||
EmitStringOutEpilogue(wrapper, native, p, body, il, GetGeneratedVariable(generatedVariables, p.Name + "_string_ptr", body));
|
||||
}
|
||||
|
||||
if (!p.ParameterType.IsArray && p.ParameterType.Name == "String")
|
||||
|
@ -564,44 +575,73 @@ namespace OpenTK.Rewrite
|
|||
body.Variables.Contains(v.Definition));
|
||||
}
|
||||
|
||||
private static GeneratedVariableIdentifier EmitStringBuilderParameter(MethodDefinition method, ParameterDefinition parameter, MethodBody body, ILProcessor il)
|
||||
private static GeneratedVariableIdentifier EmitStringOutParameter(MethodDefinition method, ParameterDefinition parameter, MethodBody body, ILProcessor il)
|
||||
{
|
||||
var p = parameter.ParameterType;
|
||||
|
||||
// void GetShaderInfoLog(..., StringBuilder foo)
|
||||
// IntPtr foo_sb_ptr;
|
||||
// void GetShaderInfoLog(..., out String foo)
|
||||
// IntPtr foo_string_ptr;
|
||||
// try {
|
||||
// foo_sb_ptr = Marshal.AllocHGlobal(sb.Capacity + 1);
|
||||
// glGetShaderInfoLog(..., foo_sb_ptr);
|
||||
// MarshalPtrToStringBuilder(foo_sb_ptr, sb);
|
||||
// foo_string_ptr = Marshal.AllocHGlobal(count + 1);
|
||||
// glGetShaderInfoLog(..., foo_string_ptr);
|
||||
// foo = MarshalPtrToString(foo_string_ptr);
|
||||
// }
|
||||
// finally {
|
||||
// Marshal.FreeHGlobal(sb_ptr);
|
||||
// Marshal.FreeHGlobal(foo_string_ptr);
|
||||
// }
|
||||
// Make sure we have imported StringBuilder::Capacity and Marshal::AllocHGlobal
|
||||
var sb_get_capacity = method.Module.ImportReference(TypeStringBuilder.Methods.First(m => m.Name == "get_Capacity"));
|
||||
// Make sure we have imported Marshal::AllocHGlobal
|
||||
var alloc_hglobal = method.Module.ImportReference(TypeMarshal.Methods.First(m => m.Name == "AllocHGlobal"));
|
||||
|
||||
// IntPtr ptr;
|
||||
var variableDefinition = new VariableDefinition(TypeIntPtr);
|
||||
body.Variables.Add(variableDefinition);
|
||||
int stringBuilderPtrIndex = body.Variables.Count - 1;
|
||||
int stringPtrIndex = body.Variables.Count - 1;
|
||||
|
||||
GeneratedVariableIdentifier stringBuilderPtrVar = new GeneratedVariableIdentifier(body, variableDefinition, parameter.Name + "_sb_ptr");
|
||||
GeneratedVariableIdentifier stringPtrVar = new GeneratedVariableIdentifier(body, variableDefinition, parameter.Name + "_string_ptr");
|
||||
|
||||
// ptr = Marshal.AllocHGlobal(sb.Capacity + 1);
|
||||
il.Emit(OpCodes.Callvirt, sb_get_capacity);
|
||||
// ptr = Marshal.AllocHGlobal(count + 1);
|
||||
var count = GetCountAttribute(parameter);
|
||||
if (count == null)
|
||||
{
|
||||
// We need a count attribute so we know what size to make the
|
||||
// string buffer. Currently every string out parameter has a
|
||||
// count attribute but this check is in place to make things
|
||||
// clearer if this case is ever hit.
|
||||
throw new InvalidOperationException(string.Format("{0}({1}) doesn't have a count attribute", method.Name, parameter.Name));
|
||||
}
|
||||
|
||||
if (count.Count != 0)
|
||||
{
|
||||
// Fixed size
|
||||
il.Emit(OpCodes.Ldc_I4, count.Count);
|
||||
}
|
||||
else if (count.Parameter != null)
|
||||
{
|
||||
// Parameter sized
|
||||
var countVariable = EmitCountVariable(method, body, il, count.Parameter);
|
||||
il.Emit(OpCodes.Ldloc, countVariable.Index);
|
||||
}
|
||||
else if (count.Computed != null)
|
||||
{
|
||||
// We don't handle count.Computed. Computed counts are hard and
|
||||
// require manual reading of the specification for each one.
|
||||
// But currently no string out parameters require it.
|
||||
throw new NotSupportedException(string.Format("{0}({1}) requires a computed count: {2}", method.Name, parameter.Name, count.Computed));
|
||||
}
|
||||
|
||||
il.Emit(OpCodes.Ldc_I4, 1);
|
||||
il.Emit(OpCodes.Add);
|
||||
il.Emit(OpCodes.Call, alloc_hglobal);
|
||||
il.Emit(OpCodes.Stloc, stringBuilderPtrIndex);
|
||||
il.Emit(OpCodes.Ldloc, stringBuilderPtrIndex);
|
||||
il.Emit(OpCodes.Stloc, stringPtrIndex);
|
||||
il.Emit(OpCodes.Ldloc, stringPtrIndex);
|
||||
|
||||
// We'll emit the try-finally block in the epilogue implementation,
|
||||
// because we haven't yet emitted all necessary instructions here.
|
||||
|
||||
return stringBuilderPtrVar;
|
||||
return stringPtrVar;
|
||||
}
|
||||
|
||||
private static void EmitStringBuilderEpilogue(MethodDefinition wrapper, MethodDefinition native,
|
||||
private static void EmitStringOutEpilogue(MethodDefinition wrapper, MethodDefinition native,
|
||||
ParameterDefinition parameter, MethodBody body, ILProcessor il, GeneratedVariableIdentifier generatedPtrVar)
|
||||
{
|
||||
if (generatedPtrVar == null)
|
||||
|
@ -609,38 +649,36 @@ namespace OpenTK.Rewrite
|
|||
throw new ArgumentNullException(nameof(generatedPtrVar));
|
||||
}
|
||||
|
||||
var p = parameter.ParameterType;
|
||||
if (p.Name == "StringBuilder")
|
||||
{
|
||||
// void GetShaderInfoLog(..., StringBuilder foo)
|
||||
// try {
|
||||
// foo_sb_ptr = Marshal.AllocHGlobal(sb.Capacity + 1); -- already emitted
|
||||
// glGetShaderInfoLog(..., foo_sb_ptr); -- already emitted
|
||||
// MarshalPtrToStringBuilder(foo_sb_ptr, foo);
|
||||
// }
|
||||
// finally {
|
||||
// Marshal.FreeHGlobal(foo_sb_ptr);
|
||||
// }
|
||||
// void GetShaderInfoLog(..., out String foo)
|
||||
// IntPtr foo_string_ptr;
|
||||
// try {
|
||||
// foo_string_ptr = Marshal.AllocHGlobal(count + 1);
|
||||
// glGetShaderInfoLog(..., foo_string_ptr);
|
||||
// foo = MarshalPtrToString(foo_string_ptr);
|
||||
// }
|
||||
// finally {
|
||||
// Marshal.FreeHGlobal(foo_string_ptr);
|
||||
// }
|
||||
|
||||
// Make sure we have imported BindingsBase::MasrhalPtrToStringBuilder and Marshal::FreeHGlobal
|
||||
var ptr_to_sb = wrapper.Module.ImportReference(TypeBindingsBase.Methods.First(m => m.Name == "MarshalPtrToStringBuilder"));
|
||||
var free_hglobal = wrapper.Module.ImportReference(TypeMarshal.Methods.First(m => m.Name == "FreeHGlobal"));
|
||||
// Make sure we have imported BindingsBase::MasrhalPtrToString and Marshal::FreeHGlobal
|
||||
var ptr_to_str = wrapper.Module.ImportReference(TypeBindingsBase.Methods.First(m => m.Name == "MarshalPtrToString"));
|
||||
var free_hglobal = wrapper.Module.ImportReference(TypeMarshal.Methods.First(m => m.Name == "FreeHGlobal"));
|
||||
|
||||
var block = new ExceptionHandler(ExceptionHandlerType.Finally);
|
||||
block.TryStart = body.Instructions[0];
|
||||
var block = new ExceptionHandler(ExceptionHandlerType.Finally);
|
||||
block.TryStart = body.Instructions[0];
|
||||
|
||||
il.Emit(OpCodes.Ldloc, generatedPtrVar.Definition.Index);
|
||||
il.Emit(OpCodes.Ldarg, parameter.Index);
|
||||
il.Emit(OpCodes.Call, ptr_to_sb);
|
||||
il.Emit(OpCodes.Ldloc, generatedPtrVar.Definition.Index);
|
||||
il.Emit(OpCodes.Ldarg, parameter.Index);
|
||||
il.Emit(OpCodes.Call, ptr_to_str);
|
||||
il.Emit(OpCodes.Starg, parameter.Index);
|
||||
|
||||
block.TryEnd = body.Instructions.Last();
|
||||
block.HandlerStart = body.Instructions.Last();
|
||||
block.TryEnd = body.Instructions.Last();
|
||||
block.HandlerStart = body.Instructions.Last();
|
||||
|
||||
il.Emit(OpCodes.Ldloc, generatedPtrVar.Definition.Index);
|
||||
il.Emit(OpCodes.Call, free_hglobal);
|
||||
il.Emit(OpCodes.Ldloc, generatedPtrVar.Definition.Index);
|
||||
il.Emit(OpCodes.Call, free_hglobal);
|
||||
|
||||
block.HandlerEnd = body.Instructions.Last();
|
||||
}
|
||||
block.HandlerEnd = body.Instructions.Last();
|
||||
}
|
||||
|
||||
private static GeneratedVariableIdentifier EmitStringParameter(MethodDefinition wrapper, ParameterDefinition parameter, MethodBody body,
|
||||
|
@ -804,6 +842,64 @@ namespace OpenTK.Rewrite
|
|||
return generatedVariables;
|
||||
}
|
||||
|
||||
private static object GetAttributeField(CustomAttribute attribute, string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var field = attribute.Fields.First(f => f.Name == name);
|
||||
return field.Argument.Value;
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static CountAttribute GetCountAttribute(ParameterDefinition parameter)
|
||||
{
|
||||
var attribute = parameter.CustomAttributes
|
||||
.FirstOrDefault(a => a.AttributeType.Name == "CountAttribute");
|
||||
|
||||
var count = new CountAttribute();
|
||||
if (attribute != null)
|
||||
{
|
||||
count.Count = (int)(GetAttributeField(attribute, "Count") ?? 0);
|
||||
count.Parameter = (string)(GetAttributeField(attribute, "Parameter"));
|
||||
count.Computed = (string)(GetAttributeField(attribute, "Computed"));
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
private static VariableDefinition EmitCountVariable(MethodDefinition method, MethodBody body, ILProcessor il, string countParameter)
|
||||
{
|
||||
var countVariable = new VariableDefinition(TypeInt32);
|
||||
body.Variables.Add(countVariable);
|
||||
|
||||
// Parameter will either by a simple name or an
|
||||
// expression like "name*5"
|
||||
var parameter = method.Parameters.FirstOrDefault(
|
||||
param => param.Name == countParameter);
|
||||
if (parameter != null)
|
||||
{
|
||||
il.Emit(OpCodes.Ldarg, parameter.Index);
|
||||
il.Emit(OpCodes.Stloc, countVariable.Index);
|
||||
}
|
||||
else
|
||||
{
|
||||
var operands = countParameter.Split('*');
|
||||
parameter = method.Parameters.FirstOrDefault(
|
||||
param => param.Name == operands[0]);
|
||||
var scale = int.Parse(operands[1]);
|
||||
|
||||
il.Emit(OpCodes.Ldarg, parameter.Index);
|
||||
il.Emit(OpCodes.Ldc_I4, scale);
|
||||
il.Emit(OpCodes.Mul);
|
||||
il.Emit(OpCodes.Stloc, countVariable.Index);
|
||||
}
|
||||
return countVariable;
|
||||
}
|
||||
|
||||
private static List<GeneratedVariableIdentifier> EmitParameters(MethodDefinition method, MethodDefinition native, MethodBody body, ILProcessor il)
|
||||
{
|
||||
List<GeneratedVariableIdentifier> generatedVariables = new List<GeneratedVariableIdentifier>();
|
||||
|
@ -819,9 +915,9 @@ namespace OpenTK.Rewrite
|
|||
// We need to convert the loaded argument to IntPtr.
|
||||
il.Emit(OpCodes.Conv_I);
|
||||
}
|
||||
else if (p.Name == "StringBuilder")
|
||||
else if (p.Name == "String" && !p.IsArray && parameter.IsOut)
|
||||
{
|
||||
generatedVariables.Add(EmitStringBuilderParameter(method, parameter, body, il));
|
||||
generatedVariables.Add(EmitStringOutParameter(method, parameter, body, il));
|
||||
}
|
||||
else if (p.Name == "String" && !p.IsArray)
|
||||
{
|
||||
|
|
|
@ -76,27 +76,24 @@ namespace OpenTK
|
|||
/// This method supports OpenTK and is not intended to be called by user code.
|
||||
/// </summary>
|
||||
/// <param name="ptr">A pointer to a null-terminated byte array.</param>
|
||||
/// <param name="sb">The StringBuilder to receive the contents of the pointer.</param>
|
||||
protected static void MarshalPtrToStringBuilder(IntPtr ptr, StringBuilder sb)
|
||||
protected static string MarshalPtrToString(IntPtr ptr)
|
||||
{
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
throw new ArgumentException("ptr");
|
||||
}
|
||||
if (sb == null)
|
||||
{
|
||||
throw new ArgumentNullException("sb");
|
||||
}
|
||||
|
||||
sb.Length = 0;
|
||||
for (int i = 0; ; i++)
|
||||
unsafe
|
||||
{
|
||||
byte b = Marshal.ReadByte(ptr, i);
|
||||
if (b == 0)
|
||||
sbyte* str = (sbyte*)ptr.ToPointer();
|
||||
int len = 0;
|
||||
while(*str != 0)
|
||||
{
|
||||
return;
|
||||
++len;
|
||||
++str;
|
||||
}
|
||||
sb.Append((char)b);
|
||||
|
||||
return new string(str, 0, len, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
63
src/OpenTK/CountAttribute.cs
Normal file
63
src/OpenTK/CountAttribute.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2017 the Open Toolkit library, except where noted.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to indicate how to calculate the count/length of a parameter.
|
||||
///
|
||||
/// Only one of Parameter, Count, or Computed should be set.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class CountAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies another parameter to look at for the count of this parameter.
|
||||
/// </summary>
|
||||
public string Parameter;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a fixed count.
|
||||
/// </summary>
|
||||
public int Count;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a computed count based on other parameters.
|
||||
/// </summary>
|
||||
public string Computed;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new CountAttribute instance.
|
||||
/// </summary>
|
||||
public CountAttribute()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -175,10 +175,10 @@ namespace OpenTK.Graphics.ES20
|
|||
{
|
||||
int length;
|
||||
GetProgram(program, GetProgramParameterName.ActiveAttributeMaxLength, out length);
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2);
|
||||
string str;
|
||||
|
||||
GetActiveAttrib(program, index, sb.Capacity, out length, out size, out type, sb);
|
||||
return sb.ToString();
|
||||
GetActiveAttrib(program, index, length == 0 ? 1 : length * 2, out length, out size, out type, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type)
|
||||
|
@ -186,9 +186,9 @@ namespace OpenTK.Graphics.ES20
|
|||
int length;
|
||||
GetProgram(program, GetProgramParameterName.ActiveUniformMaxLength, out length);
|
||||
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length);
|
||||
GetActiveUniform(program, uniformIndex, sb.Capacity, out length, out size, out type, sb);
|
||||
return sb.ToString();
|
||||
string str;
|
||||
GetActiveUniform(program, uniformIndex, length == 0 ? 1 : length, out length, out size, out type, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void ShaderSource(Int32 shader, System.String @string)
|
||||
|
@ -218,9 +218,7 @@ namespace OpenTK.Graphics.ES20
|
|||
info = String.Empty;
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(length * 2);
|
||||
GL.GetShaderInfoLog((UInt32)shader, sb.Capacity, &length, sb);
|
||||
info = sb.ToString();
|
||||
GL.GetShaderInfoLog((UInt32)shader, length * 2, &length, out info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,9 +239,7 @@ namespace OpenTK.Graphics.ES20
|
|||
info = String.Empty;
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(length * 2);
|
||||
GL.GetProgramInfoLog((UInt32)program, sb.Capacity, &length, sb);
|
||||
info = sb.ToString();
|
||||
GL.GetProgramInfoLog((UInt32)program, length * 2, &length, out info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -175,10 +175,10 @@ namespace OpenTK.Graphics.ES30
|
|||
{
|
||||
int length;
|
||||
GetProgram(program, ES30.GetProgramParameterName.ActiveAttributeMaxLength, out length);
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2);
|
||||
string str;
|
||||
|
||||
GetActiveAttrib(program, index, sb.Capacity, out length, out size, out type, sb);
|
||||
return sb.ToString();
|
||||
GetActiveAttrib(program, index, length == 0 ? 1 : length * 2, out length, out size, out type, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type)
|
||||
|
@ -186,9 +186,9 @@ namespace OpenTK.Graphics.ES30
|
|||
int length;
|
||||
GetProgram(program, ES30.GetProgramParameterName.ActiveUniformMaxLength, out length);
|
||||
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length);
|
||||
GetActiveUniform(program, uniformIndex, sb.Capacity, out length, out size, out type, sb);
|
||||
return sb.ToString();
|
||||
string str;
|
||||
GetActiveUniform(program, uniformIndex, length == 0 ? 1 : length, out length, out size, out type, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void ShaderSource(Int32 shader, System.String @string)
|
||||
|
@ -218,9 +218,7 @@ namespace OpenTK.Graphics.ES30
|
|||
info = String.Empty;
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(length * 2);
|
||||
GL.GetShaderInfoLog((UInt32)shader, sb.Capacity, &length, sb);
|
||||
info = sb.ToString();
|
||||
GL.GetShaderInfoLog((UInt32)shader, length * 2, &length, out info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,9 +239,7 @@ namespace OpenTK.Graphics.ES30
|
|||
info = String.Empty;
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(length * 2);
|
||||
GL.GetProgramInfoLog((UInt32)program, sb.Capacity, &length, sb);
|
||||
info = sb.ToString();
|
||||
GL.GetProgramInfoLog((UInt32)program, length * 2, &length, out info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1889,10 +1889,10 @@ namespace OpenTK.Graphics.OpenGL
|
|||
{
|
||||
int length;
|
||||
GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveAttributeMaxLength, out length);
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2);
|
||||
string str;
|
||||
|
||||
GetActiveAttrib(program, index, sb.Capacity, out length, out size, out type, sb);
|
||||
return sb.ToString();
|
||||
GetActiveAttrib(program, index, length == 0 ? 1 : length * 2, out length, out size, out type, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1919,9 +1919,9 @@ namespace OpenTK.Graphics.OpenGL
|
|||
int length;
|
||||
GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformMaxLength, out length);
|
||||
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length);
|
||||
GetActiveUniform(program, uniformIndex, sb.Capacity, out length, out size, out type, sb);
|
||||
return sb.ToString();
|
||||
string str;
|
||||
GetActiveUniform(program, uniformIndex, length == 0 ? 1 : length, out length, out size, out type, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1941,10 +1941,10 @@ namespace OpenTK.Graphics.OpenGL
|
|||
{
|
||||
int length;
|
||||
GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformMaxLength, out length);
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2);
|
||||
string str;
|
||||
|
||||
GetActiveUniformName(program, uniformIndex, sb.Capacity, out length, sb);
|
||||
return sb.ToString();
|
||||
GetActiveUniformName(program, uniformIndex, length == 0 ? 1 : length * 2, out length, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1964,10 +1964,10 @@ namespace OpenTK.Graphics.OpenGL
|
|||
{
|
||||
int length;
|
||||
GetProgram(program, OpenTK.Graphics.OpenGL.GetProgramParameterName.ActiveUniformBlockMaxNameLength, out length);
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2);
|
||||
string str;
|
||||
|
||||
GetActiveUniformBlockName(program, uniformIndex, sb.Capacity, out length, sb);
|
||||
return sb.ToString();
|
||||
GetActiveUniformBlockName(program, uniformIndex, length == 0 ? 1 : length * 2, out length, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2027,9 +2027,7 @@ namespace OpenTK.Graphics.OpenGL
|
|||
info = String.Empty;
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(length * 2);
|
||||
GL.GetShaderInfoLog((UInt32)shader, sb.Capacity, &length, sb);
|
||||
info = sb.ToString();
|
||||
GL.GetShaderInfoLog((UInt32)shader, length * 2, &length, out info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2070,9 +2068,7 @@ namespace OpenTK.Graphics.OpenGL
|
|||
info = String.Empty;
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(length * 2);
|
||||
GL.GetProgramInfoLog((UInt32)program, sb.Capacity, &length, sb);
|
||||
info = sb.ToString();
|
||||
GL.GetProgramInfoLog((UInt32)program, length * 2, &length, out info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -246,10 +246,10 @@ namespace OpenTK.Graphics.OpenGL4
|
|||
{
|
||||
int length;
|
||||
GetProgram(program, OpenGL4.GetProgramParameterName.ActiveAttributeMaxLength, out length);
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length * 2);
|
||||
string str;
|
||||
|
||||
GetActiveAttrib(program, index, sb.Capacity, out length, out size, out type, sb);
|
||||
return sb.ToString();
|
||||
GetActiveAttrib(program, index, length == 0 ? 1 : length * 2, out length, out size, out type, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static string GetActiveUniform(int program, int uniformIndex, out int size, out ActiveUniformType type)
|
||||
|
@ -257,9 +257,9 @@ namespace OpenTK.Graphics.OpenGL4
|
|||
int length;
|
||||
GetProgram(program, OpenGL4.GetProgramParameterName.ActiveUniformMaxLength, out length);
|
||||
|
||||
StringBuilder sb = new StringBuilder(length == 0 ? 1 : length);
|
||||
GetActiveUniform(program, uniformIndex, sb.Capacity, out length, out size, out type, sb);
|
||||
return sb.ToString();
|
||||
string str;
|
||||
GetActiveUniform(program, uniformIndex, length == 0 ? 1 : length, out length, out size, out type, out str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void ShaderSource(Int32 shader, System.String @string)
|
||||
|
@ -289,9 +289,7 @@ namespace OpenTK.Graphics.OpenGL4
|
|||
info = String.Empty;
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(length * 2);
|
||||
GL.GetShaderInfoLog((UInt32)shader, sb.Capacity, &length, sb);
|
||||
info = sb.ToString();
|
||||
GL.GetShaderInfoLog((UInt32)shader, length * 2, &length, out info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,9 +310,7 @@ namespace OpenTK.Graphics.OpenGL4
|
|||
info = String.Empty;
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(length * 2);
|
||||
GL.GetProgramInfoLog((UInt32)program, sb.Capacity, &length, sb);
|
||||
info = sb.ToString();
|
||||
GL.GetProgramInfoLog((UInt32)program, length * 2, &length, out info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutoGeneratedAttribute.cs" />
|
||||
<Compile Include="CountAttribute.cs" />
|
||||
<Compile Include="BindingsBase.cs" />
|
||||
<Compile Include="BlittableValueType.cs" />
|
||||
<Compile Include="Configuration.cs" />
|
||||
|
|
|
@ -167,6 +167,9 @@
|
|||
<Compile Include="AutoGeneratedAttribute.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CountAttribute.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NativeWindow.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutoGeneratedAttribute.cs" />
|
||||
<Compile Include="CountAttribute.cs" />
|
||||
<Compile Include="BindingsBase.cs" />
|
||||
<Compile Include="BlittableValueType.cs" />
|
||||
<Compile Include="Configuration.cs" />
|
||||
|
|
Loading…
Reference in a new issue