2004-02-01 20:03:26 +00:00
|
|
|
##
|
2007-12-28 01:47:25 +00:00
|
|
|
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
|
|
|
|
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
|
2004-02-01 20:03:26 +00:00
|
|
|
##
|
|
|
|
## This program is distributed under the terms and conditions of the GNU
|
|
|
|
## General Public License Version 2 as published by the Free Software
|
|
|
|
## Foundation or, at your option, any later version.
|
2003-07-06 15:01:13 +00:00
|
|
|
|
|
|
|
my %regex = (
|
|
|
|
extname => qr/^[A-Z][A-Za-z0-9_]+$/,
|
2003-07-08 16:43:30 +00:00
|
|
|
exturl => qr/^http.+$/,
|
2003-07-06 15:01:13 +00:00
|
|
|
function => qr/^(.+) ([a-z][a-z0-9_]*) \((.+)\)$/i,
|
2009-08-03 17:03:50 +00:00
|
|
|
token => qr/^([A-Z][A-Z0-9_x]*)\s+((?:0x)?[0-9A-Fa-f]+|[A-Z][A-Z0-9_]*)$/,
|
2011-01-01 15:30:11 +00:00
|
|
|
type => qr/^typedef\s+(.+)$/,
|
2003-07-06 15:01:13 +00:00
|
|
|
exact => qr/.*;$/,
|
|
|
|
);
|
|
|
|
|
|
|
|
# prefix function name with glew
|
|
|
|
sub prefixname($)
|
|
|
|
{
|
|
|
|
my $name = $_[0];
|
2011-03-28 04:21:43 +00:00
|
|
|
$name =~ s/^(.*?)gl/__$1glew/;
|
2004-02-01 18:13:05 +00:00
|
|
|
return $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
# prefix function name with glew
|
|
|
|
sub prefix_varname($)
|
|
|
|
{
|
|
|
|
my $name = $_[0];
|
2011-03-28 04:21:43 +00:00
|
|
|
$name =~ s/^(.*?)GL(X*?)EW/__$1GL$2EW/;
|
2003-07-06 15:01:13 +00:00
|
|
|
return $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sub make_exact($)
|
|
|
|
{
|
2007-03-02 04:40:31 +00:00
|
|
|
my $exact = $_[0];
|
|
|
|
$exact =~ s/(; |{)/$1\n/g;
|
|
|
|
return $exact;
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub make_separator($)
|
|
|
|
{
|
|
|
|
my $extname = $_[0];
|
|
|
|
my $l = length $extname;
|
|
|
|
my $s = (71 - $l)/2;
|
|
|
|
print "/* ";
|
|
|
|
my $j = 3;
|
|
|
|
for (my $i = 0; $i < $s; $i++)
|
|
|
|
{
|
|
|
|
print "-";
|
|
|
|
$j++;
|
|
|
|
}
|
|
|
|
print " $_[0] ";
|
|
|
|
$j += $l + 2;
|
|
|
|
while ($j < 76)
|
|
|
|
{
|
|
|
|
print "-";
|
|
|
|
$j++;
|
|
|
|
}
|
|
|
|
print " */\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sub parse_ext($)
|
|
|
|
{
|
|
|
|
my $filename = shift;
|
|
|
|
my %functions = ();
|
|
|
|
my %tokens = ();
|
2011-01-01 15:30:11 +00:00
|
|
|
my @types = ();
|
2003-07-06 15:01:13 +00:00
|
|
|
my @exacts = ();
|
2010-03-05 18:19:59 +00:00
|
|
|
my $extname = ""; # Full extension name GL_FOO_extension
|
|
|
|
my $exturl = ""; # Info URL
|
|
|
|
my $extstring = ""; # Relevant extension string
|
|
|
|
|
2003-07-06 15:01:13 +00:00
|
|
|
open EXT, "<$filename" or return;
|
|
|
|
|
2010-03-05 18:19:59 +00:00
|
|
|
# As of GLEW 1.5.3 the first three lines _must_ be
|
|
|
|
# the extension name, the URL and the GL extension
|
|
|
|
# string (which might be different to the name)
|
|
|
|
#
|
|
|
|
# For example GL_NV_geometry_program4 is available
|
|
|
|
# iff GL_NV_gpu_program4 appears in the extension
|
|
|
|
# string.
|
|
|
|
#
|
|
|
|
# For core OpenGL versions, the third line should
|
|
|
|
# be blank.
|
|
|
|
#
|
|
|
|
# If the URL is unknown, the second line should be
|
|
|
|
# blank.
|
|
|
|
|
|
|
|
$extname = readline(*EXT);
|
|
|
|
$exturl = readline(*EXT);
|
|
|
|
$extstring = readline(*EXT);
|
|
|
|
|
|
|
|
chomp($extname);
|
|
|
|
chomp($exturl);
|
|
|
|
chomp($extstring);
|
|
|
|
|
2003-07-06 15:01:13 +00:00
|
|
|
while(<EXT>)
|
|
|
|
{
|
|
|
|
chomp;
|
2010-03-05 18:19:59 +00:00
|
|
|
if (s/^\s+//)
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
|
|
|
if (/$regex{exact}/)
|
|
|
|
{
|
2010-03-05 18:19:59 +00:00
|
|
|
push @exacts, $_;
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
|
|
|
elsif (/$regex{type}/)
|
|
|
|
{
|
2011-01-01 15:30:11 +00:00
|
|
|
push @types, $_;
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
|
|
|
elsif (/$regex{token}/)
|
|
|
|
{
|
|
|
|
my ($name, $value) = ($1, $2);
|
|
|
|
$tokens{$name} = $value;
|
|
|
|
}
|
|
|
|
elsif (/$regex{function}/)
|
|
|
|
{
|
|
|
|
my ($return, $name, $parms) = ($1, $2, $3);
|
|
|
|
$functions{$name} = {
|
|
|
|
rtype => $return,
|
|
|
|
parms => $parms,
|
|
|
|
};
|
2009-08-03 17:03:50 +00:00
|
|
|
} else {
|
|
|
|
print STDERR "'$_' matched no regex.\n";
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close EXT;
|
|
|
|
|
2011-01-01 15:30:11 +00:00
|
|
|
return ($extname, $exturl, $extstring, \@types, \%tokens, \%functions, \@exacts);
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub output_tokens($$)
|
|
|
|
{
|
|
|
|
my ($tbl, $fnc) = @_;
|
|
|
|
if (keys %{$tbl})
|
|
|
|
{
|
|
|
|
local $, = "\n";
|
|
|
|
print "\n";
|
|
|
|
print map { &{$fnc}($_, $tbl->{$_}) } sort { hex ${$tbl}{$a} <=> hex ${$tbl}{$b} } keys %{$tbl};
|
|
|
|
print "\n";
|
2009-08-03 17:03:50 +00:00
|
|
|
} else {
|
2009-11-09 17:40:24 +00:00
|
|
|
print STDERR "no keys in table!\n";
|
2003-07-06 15:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub output_types($$)
|
|
|
|
{
|
|
|
|
my ($tbl, $fnc) = @_;
|
2011-01-01 15:30:11 +00:00
|
|
|
if (scalar @{$tbl})
|
2003-07-06 15:01:13 +00:00
|
|
|
{
|
|
|
|
local $, = "\n";
|
|
|
|
print "\n";
|
2011-01-01 15:30:11 +00:00
|
|
|
print map { &{$fnc}($_) } sort @{$tbl};
|
2003-07-06 15:01:13 +00:00
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub output_decls($$)
|
|
|
|
{
|
|
|
|
my ($tbl, $fnc) = @_;
|
|
|
|
if (keys %{$tbl})
|
|
|
|
{
|
|
|
|
local $, = "\n";
|
|
|
|
print "\n";
|
|
|
|
print map { &{$fnc}($_, $tbl->{$_}) } sort keys %{$tbl};
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub output_exacts($$)
|
|
|
|
{
|
|
|
|
my ($tbl, $fnc) = @_;
|
|
|
|
if (scalar @{$tbl})
|
|
|
|
{
|
|
|
|
local $, = "\n";
|
|
|
|
print "\n";
|
|
|
|
print map { &{$fnc}($_) } sort @{$tbl};
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|