[CoreSupport] Add code generation for sorted array of extension strings, which can index into array of pointers of extension enable flags.

This commit is contained in:
Nigel Stewart 2015-02-20 22:47:51 +10:00
parent 9384b86bd8
commit 0157bd8a9a
3 changed files with 83 additions and 1 deletions

View File

@ -198,7 +198,14 @@ $(S.DEST)/glew.c: $(EXT)/.dummy
$(BIN)/make_def_var.pl GL $(GL_CORE_SPEC) >> $@ $(BIN)/make_def_var.pl GL $(GL_CORE_SPEC) >> $@
$(BIN)/make_def_var.pl GL $(GL_EXT_SPEC) >> $@ $(BIN)/make_def_var.pl GL $(GL_EXT_SPEC) >> $@
echo -e "\n#endif /* !GLEW_MX */\n" >> $@; echo -e "\n#endif /* !GLEW_MX */\n" >> $@;
echo -e "" >> $@; echo -e "\nstatic const char * _glewExtensionLookup[] = {" >> $@;
$(BIN)/make_index.pl $(GL_EXT_SPEC) >> $@
echo -e " NULL\n};\n" >> $@;
echo -e "\n#if !defined(GLEW_MX)" >> $@;
echo -e "\nstatic GLboolean* _glewEnabled[] = {" >> $@;
$(BIN)/make_enable_index.pl $(GL_CORE_SPEC) $(GL_EXT_SPEC) >> $@
echo -e " NULL\n};\n" >> $@;
echo -e "\n#endif /* !GLEW_MX */\n" >> $@;
$(BIN)/make_initd.pl GL $(GL_CORE_SPEC) >> $@ $(BIN)/make_initd.pl GL $(GL_CORE_SPEC) >> $@
$(BIN)/make_initd.pl GL $(GL_EXT_SPEC) >> $@ $(BIN)/make_initd.pl GL $(GL_EXT_SPEC) >> $@
echo -e "" >> $@; echo -e "" >> $@;

37
auto/bin/make_enable_index.pl Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
##
## 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.
use strict;
use warnings;
do 'bin/make.pl';
##
## Make Extension-enabled Index
##
my @extlist = ();
if (@ARGV)
{
@extlist = @ARGV;
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) =
parse_ext($ext);
my $extvar = $extname;
$extvar =~ s/GL(X*)_/GL$1EW_/;
print "#ifdef $extname\n";
print " &__$extvar,\n";
print "#endif\n";
}
}

38
auto/bin/make_index.pl Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/perl
##
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
##
## 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.
use strict;
use warnings;
do 'bin/make.pl';
##
## Make Index
##
## Output sorted array of extension strings for indexing into extension
## enable/disable flags. This provides a way to convert an extension string
## into an integer index.
##
my @extlist = ();
if (@ARGV)
{
@extlist = @ARGV;
foreach my $ext (sort @extlist)
{
my ($extname, $exturl, $extstring, $types, $tokens, $functions, $exacts) =
parse_ext($ext);
print "#ifdef $extname\n";
print " \"$extstring\",\n";
print "#endif\n";
}
}