Support function pointer typedefs in the extension files, rather than hard-coding those directly into the header. Enables support for AMD_debug_output, ARB_debug_output and ARB_cl_event in SCI GLEW branch.

This commit is contained in:
Nigel Stewart 2011-01-01 09:30:11 -06:00
parent 17dd9d8fa5
commit 6acc3d0e85
4 changed files with 26 additions and 29 deletions

View File

@ -11,7 +11,7 @@ my %regex = (
exturl => qr/^http.+$/, exturl => qr/^http.+$/,
function => qr/^(.+) ([a-z][a-z0-9_]*) \((.+)\)$/i, function => qr/^(.+) ([a-z][a-z0-9_]*) \((.+)\)$/i,
token => qr/^([A-Z][A-Z0-9_x]*)\s+((?:0x)?[0-9A-Fa-f]+|[A-Z][A-Z0-9_]*)$/, token => qr/^([A-Z][A-Z0-9_x]*)\s+((?:0x)?[0-9A-Fa-f]+|[A-Z][A-Z0-9_]*)$/,
type => qr/^typedef\s+(.+)\s+([\*A-Za-z0-9_]+)$/, type => qr/^typedef\s+(.+)$/,
exact => qr/.*;$/, exact => qr/.*;$/,
); );
@ -69,7 +69,7 @@ sub parse_ext($)
my $filename = shift; my $filename = shift;
my %functions = (); my %functions = ();
my %tokens = (); my %tokens = ();
my %types = (); my @types = ();
my @exacts = (); my @exacts = ();
my $extname = ""; # Full extension name GL_FOO_extension my $extname = ""; # Full extension name GL_FOO_extension
my $exturl = ""; # Info URL my $exturl = ""; # Info URL
@ -110,8 +110,7 @@ sub parse_ext($)
} }
elsif (/$regex{type}/) elsif (/$regex{type}/)
{ {
my ($value, $name) = ($1, $2); push @types, $_;
$types{$name} = $value;
} }
elsif (/$regex{token}/) elsif (/$regex{token}/)
{ {
@ -133,7 +132,7 @@ sub parse_ext($)
close EXT; close EXT;
return ($extname, $exturl, $extstring, \%types, \%tokens, \%functions, \@exacts); return ($extname, $exturl, $extstring, \@types, \%tokens, \%functions, \@exacts);
} }
sub output_tokens($$) sub output_tokens($$)
@ -153,11 +152,11 @@ sub output_tokens($$)
sub output_types($$) sub output_types($$)
{ {
my ($tbl, $fnc) = @_; my ($tbl, $fnc) = @_;
if (keys %{$tbl}) if (scalar @{$tbl})
{ {
local $, = "\n"; local $, = "\n";
print "\n"; print "\n";
print map { &{$fnc}($_, $tbl->{$_}) } sort { ${$tbl}{$a} cmp ${$tbl}{$b} } keys %{$tbl}; print map { &{$fnc}($_) } sort @{$tbl};
print "\n"; print "\n";
} }
} }

View File

@ -21,7 +21,7 @@ sub make_define($$)
# type declaration # type declaration
sub make_type($$) sub make_type($$)
{ {
return "typedef $_[1] $_[0];" return "@_;"
} }
# function pointer type declaration # function pointer type declaration

View File

@ -299,6 +299,25 @@ EOT
grep -v "glGetPointerv" $1/GL_EXT_vertex_array > tmp grep -v "glGetPointerv" $1/GL_EXT_vertex_array > tmp
mv tmp $1/GL_EXT_vertex_array mv tmp $1/GL_EXT_vertex_array
# add typedef to GL_AMD_debug_output
# parse_spec.pl can't parse typedefs from New Types section, but ought to
cat >> $1/GL_AMD_debug_output <<EOT
typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam)
EOT
# add typedef to GL_ARB_debug_output
# parse_spec.pl can't parse typedefs from New Types section, but ought to
cat >> $1/GL_ARB_debug_output <<EOT
typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam)
EOT
# add typedefs to GL_ARB_cl_event
# parse_spec.pl can't parse typedefs from New Types section, but ought to
cat >> $1/GL_ARB_cl_event <<EOT
typedef struct _cl_context *cl_context
typedef struct _cl_event *cl_event
EOT
# clean up # clean up
rm -f $1/*.bak rm -f $1/*.bak

View File

@ -185,27 +185,6 @@ typedef GLuint64EXT GLuint64;
typedef struct __GLsync *GLsync; typedef struct __GLsync *GLsync;
typedef char GLchar; typedef char GLchar;
typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,
GLenum category,
GLenum severity,
GLsizei length,
const GLchar* message,
GLvoid* userParam);
/* For ARB_debug_output */
typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
const GLchar* message,
GLvoid* userParam);
/* For GL_ARB_cl_event */
typedef struct _cl_context *cl_context;
typedef struct _cl_event *cl_event;
#define GL_ACCUM 0x0100 #define GL_ACCUM 0x0100
#define GL_LOAD 0x0101 #define GL_LOAD 0x0101