Fixed an issue where "const unsigned [type] [pointer]" parameters where not parsed correctly. Solves issue [#1300]: "[OpenCL] Possible bug at CL.CreateProgramWithBinary".

This commit is contained in:
the_fiddler 2009-11-01 19:15:44 +00:00
parent ff572e83b7
commit 041c491f19
5 changed files with 67 additions and 67 deletions

View file

@ -168,7 +168,7 @@
<token name="DEVICE_TYPE_DEFAULT" value="(1 &lt;&lt; 0)" /> <token name="DEVICE_TYPE_DEFAULT" value="(1 &lt;&lt; 0)" />
<token name="DEVICE_TYPE_GPU" value="(1 &lt;&lt; 2)" /> <token name="DEVICE_TYPE_GPU" value="(1 &lt;&lt; 2)" />
</enum> </enum>
<enum name="ErrorCode" type="int"> <enum name="ErrorCodes" type="int">
<token name="BUILD_PROGRAM_FAILURE" value="-11" /> <token name="BUILD_PROGRAM_FAILURE" value="-11" />
<token name="COMPILER_NOT_AVAILABLE" value="-3" /> <token name="COMPILER_NOT_AVAILABLE" value="-3" />
<token name="DEVICE_NOT_AVAILABLE" value="-2" /> <token name="DEVICE_NOT_AVAILABLE" value="-2" />
@ -418,7 +418,7 @@
<param type="cl_uint" name="num_devices" flow="in" /> <param type="cl_uint" name="num_devices" flow="in" />
<param type="cl_device_id*" name="device_list" flow="in" /> <param type="cl_device_id*" name="device_list" flow="in" />
<param type="size_t*" name="lengths" flow="in" /> <param type="size_t*" name="lengths" flow="in" />
<param type="uchar" name="char" flow="in" /> <param type="uchar**" name="binaries" flow="in" />
<param type="cl_int*" name="binary_status" flow="in" /> <param type="cl_int*" name="binary_status" flow="in" />
<param type="cl_int*" name="errcode_ret" flow="out" /> <param type="cl_int*" name="errcode_ret" flow="out" />
</function> </function>

View file

@ -209,13 +209,17 @@ namespace CHeaderToXML
var paramaters_string = Regex.Match(line, @"\(.*\)").Captures[0].Value.TrimStart('(').TrimEnd(')'); var paramaters_string = Regex.Match(line, @"\(.*\)").Captures[0].Value.TrimStart('(').TrimEnd(')');
// This regex matches function parameters. // This regex matches function parameters.
// The first part matches functions pointers in the following format: // The first part matches function pointers in the following format:
// '[return type] (*[function pointer name])([parameter list]) [parameter name] // '[return type] (*[function pointer name])([parameter list]) [parameter name]
// where [parameter name] may or may not be in comments. // where [parameter name] may or may not be in comments.
// The second part (before the '|') matches parameters of the following formats: // The second part (after the '|') matches parameters of the following formats:
// '[return type] [parameter name]', '[return type] * [parameter name]', 'const [return type]* [parameter name]' // '[parameter type] [parameter name]', '[parameter type] [pointer] [parameter name]', 'const [parameter type][pointer] [parameter name]'
// where [parameter name] can either be inside comments (/* ... */) or not. // where [parameter name] may be inside comments (/* ... */) and [pointer] is '', '*', '**', etc.
var get_param = new Regex(@"(\w+\s\(\*\w+\)\s*\(.*\)\s*(/\*.*?\*/|\w+)? | (const\s)?\w+\s*\**\s*(/\*.*?\*/|\w+(\[.*?\])?)),?", RegexOptions.IgnorePatternWhitespace); var get_param = new Regex(@"(\w+\s\(\*\w+\)\s*\(.*\)\s*(/\*.*?\*/|\w+)? | (const\s)?(\w+\s*)+\**\s*(/\*.*?\*/|\w+(\[.*?\])?)),?", RegexOptions.IgnorePatternWhitespace);
var parameters =
(from item in get_param.Matches(paramaters_string).OfType<Match>()
select item.Captures[0].Value.TrimEnd(',')).ToList();
var fun = var fun =
new new
@ -257,7 +261,9 @@ namespace CHeaderToXML
Count = has_array_size ? Int32.Parse(array_size.Match(param_name).Value.Trim('[', ']')) : 0, Count = has_array_size ? Int32.Parse(array_size.Match(param_name).Value.Trim('[', ']')) : 0,
Flow = Flow =
param_name.EndsWith("ret") || param_name.EndsWith("ret") ||
((funcname.StartsWith("Get") || funcname.StartsWith("Gen")) && indirection_level > 0) ? ((funcname.StartsWith("Get") || funcname.StartsWith("Gen")) &&
indirection_level > 0 &&
!(funcname.EndsWith("Info") || funcname.EndsWith("IDs") || funcname.EndsWith("ImageFormats"))) ? // OpenCL contains Get*[Info|IDs|ImageFormats] methods with 'in' pointer parameters
"out" : "in" "out" : "in"
} }
}; };

View file

@ -2607,86 +2607,80 @@ namespace OpenTK.Compute.CL10
[System.CLSCompliant(false)] [System.CLSCompliant(false)]
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")] [AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
public static public static
unsafe IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, IntPtr* device_list, IntPtr* lengths, byte @char, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret) unsafe IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, IntPtr* device_list, IntPtr* lengths, byte** binaries, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret)
{ {
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list, (IntPtr*)lengths, (byte)@char, (int*)binary_status, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret); return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list, (IntPtr*)lengths, (byte**)binaries, (int*)binary_status, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret);
} }
[System.CLSCompliant(false)]
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")] [AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
public static public static
IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, IntPtr[] device_list, IntPtr[] lengths, byte @char, int[] binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode[] errcode_ret) unsafe IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, IntPtr[] device_list, IntPtr[] lengths, byte*[] binaries, int[] binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode[] errcode_ret)
{ {
unsafe fixed (IntPtr* device_list_ptr = device_list)
fixed (IntPtr* lengths_ptr = lengths)
fixed (byte** binaries_ptr = binaries)
fixed (int* binary_status_ptr = binary_status)
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = errcode_ret)
{ {
fixed (IntPtr* device_list_ptr = device_list) return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte**)binaries_ptr, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
fixed (IntPtr* lengths_ptr = lengths)
fixed (int* binary_status_ptr = binary_status)
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = errcode_ret)
{
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte)@char, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
}
}
}
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
public static
IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, ref IntPtr device_list, ref IntPtr lengths, byte @char, ref int binary_status, [OutAttribute] out OpenTK.Compute.CL10.ErrorCode errcode_ret)
{
unsafe
{
fixed (IntPtr* device_list_ptr = &device_list)
fixed (IntPtr* lengths_ptr = &lengths)
fixed (int* binary_status_ptr = &binary_status)
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = &errcode_ret)
{
IntPtr retval = Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte)@char, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
errcode_ret = *errcode_ret_ptr;
return retval;
}
} }
} }
[System.CLSCompliant(false)] [System.CLSCompliant(false)]
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")] [AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
public static public static
unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte @char, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret) unsafe IntPtr CreateProgramWithBinary(IntPtr context, Int32 num_devices, ref IntPtr device_list, ref IntPtr lengths, ref byte* binaries, ref int binary_status, [OutAttribute] out OpenTK.Compute.CL10.ErrorCode errcode_ret)
{ {
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list, (IntPtr*)lengths, (byte)@char, (int*)binary_status, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret); fixed (IntPtr* device_list_ptr = &device_list)
} fixed (IntPtr* lengths_ptr = &lengths)
fixed (byte** binaries_ptr = &binaries)
[System.CLSCompliant(false)] fixed (int* binary_status_ptr = &binary_status)
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")] fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = &errcode_ret)
public static
IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr[] device_list, IntPtr[] lengths, byte @char, int[] binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode[] errcode_ret)
{
unsafe
{ {
fixed (IntPtr* device_list_ptr = device_list) IntPtr retval = Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte**)binaries_ptr, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
fixed (IntPtr* lengths_ptr = lengths) errcode_ret = *errcode_ret_ptr;
fixed (int* binary_status_ptr = binary_status) return retval;
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = errcode_ret)
{
return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte)@char, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
}
} }
} }
[System.CLSCompliant(false)] [System.CLSCompliant(false)]
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")] [AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
public static public static
IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, ref IntPtr device_list, ref IntPtr lengths, byte @char, ref int binary_status, [OutAttribute] out OpenTK.Compute.CL10.ErrorCode errcode_ret) unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte** binaries, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret)
{ {
unsafe return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list, (IntPtr*)lengths, (byte**)binaries, (int*)binary_status, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret);
}
[System.CLSCompliant(false)]
[AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
public static
unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr[] device_list, IntPtr[] lengths, byte*[] binaries, int[] binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode[] errcode_ret)
{
fixed (IntPtr* device_list_ptr = device_list)
fixed (IntPtr* lengths_ptr = lengths)
fixed (byte** binaries_ptr = binaries)
fixed (int* binary_status_ptr = binary_status)
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = errcode_ret)
{ {
fixed (IntPtr* device_list_ptr = &device_list) return Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte**)binaries_ptr, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
fixed (IntPtr* lengths_ptr = &lengths) }
fixed (int* binary_status_ptr = &binary_status) }
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = &errcode_ret)
{ [System.CLSCompliant(false)]
IntPtr retval = Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte)@char, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr); [AutoGenerated(Category = "1.0", Version = "1.0", EntryPoint = "clCreateProgramWithBinary")]
errcode_ret = *errcode_ret_ptr; public static
return retval; unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, ref IntPtr device_list, ref IntPtr lengths, ref byte* binaries, ref int binary_status, [OutAttribute] out OpenTK.Compute.CL10.ErrorCode errcode_ret)
} {
fixed (IntPtr* device_list_ptr = &device_list)
fixed (IntPtr* lengths_ptr = &lengths)
fixed (byte** binaries_ptr = &binaries)
fixed (int* binary_status_ptr = &binary_status)
fixed (OpenTK.Compute.CL10.ErrorCode* errcode_ret_ptr = &errcode_ret)
{
IntPtr retval = Delegates.clCreateProgramWithBinary((IntPtr)context, (uint)num_devices, (IntPtr*)device_list_ptr, (IntPtr*)lengths_ptr, (byte**)binaries_ptr, (int*)binary_status_ptr, (OpenTK.Compute.CL10.ErrorCode*)errcode_ret_ptr);
errcode_ret = *errcode_ret_ptr;
return retval;
} }
} }

View file

@ -68,7 +68,7 @@ namespace OpenTK.Compute.CL10
internal extern static unsafe int CreateKernelsInProgram(IntPtr program, uint num_kernels, IntPtr* kernels, [OutAttribute] uint* num_kernels_ret); internal extern static unsafe int CreateKernelsInProgram(IntPtr program, uint num_kernels, IntPtr* kernels, [OutAttribute] uint* num_kernels_ret);
[System.Security.SuppressUnmanagedCodeSecurity()] [System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(CL.Library, EntryPoint = "clCreateProgramWithBinary", ExactSpelling = true)] [System.Runtime.InteropServices.DllImport(CL.Library, EntryPoint = "clCreateProgramWithBinary", ExactSpelling = true)]
internal extern static unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte @char, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret); internal extern static unsafe IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte** binaries, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
[System.Security.SuppressUnmanagedCodeSecurity()] [System.Security.SuppressUnmanagedCodeSecurity()]
[System.Runtime.InteropServices.DllImport(CL.Library, EntryPoint = "clCreateProgramWithSource", ExactSpelling = true)] [System.Runtime.InteropServices.DllImport(CL.Library, EntryPoint = "clCreateProgramWithSource", ExactSpelling = true)]
internal extern static unsafe IntPtr CreateProgramWithSource(IntPtr context, uint count, String[] strings, IntPtr* lengths, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret); internal extern static unsafe IntPtr CreateProgramWithSource(IntPtr context, uint count, String[] strings, IntPtr* lengths, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);

View file

@ -66,7 +66,7 @@ namespace OpenTK.Compute.CL10
internal unsafe delegate int CreateKernelsInProgram(IntPtr program, uint num_kernels, IntPtr* kernels, [OutAttribute] uint* num_kernels_ret); internal unsafe delegate int CreateKernelsInProgram(IntPtr program, uint num_kernels, IntPtr* kernels, [OutAttribute] uint* num_kernels_ret);
internal unsafe static CreateKernelsInProgram clCreateKernelsInProgram; internal unsafe static CreateKernelsInProgram clCreateKernelsInProgram;
[System.Security.SuppressUnmanagedCodeSecurity()] [System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte @char, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret); internal unsafe delegate IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr* device_list, IntPtr* lengths, byte** binaries, int* binary_status, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
internal unsafe static CreateProgramWithBinary clCreateProgramWithBinary; internal unsafe static CreateProgramWithBinary clCreateProgramWithBinary;
[System.Security.SuppressUnmanagedCodeSecurity()] [System.Security.SuppressUnmanagedCodeSecurity()]
internal unsafe delegate IntPtr CreateProgramWithSource(IntPtr context, uint count, String[] strings, IntPtr* lengths, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret); internal unsafe delegate IntPtr CreateProgramWithSource(IntPtr context, uint count, String[] strings, IntPtr* lengths, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);