1#!/usr/bin/env perl
2##
3## Copyright (C) 2008-2019, Nigel Stewart <nigels[]users sourceforge net>
4## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
5## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
6##
7## This program is distributed under the terms and conditions of the GNU
8## General Public License Version 2 as published by the Free Software
9## Foundation or, at your option, any later version.
10
11use strict;
12use warnings;
13
14use lib '.';
15do 'bin/make.pl';
16
17my @extlist = ();
18my %extensions = ();
19
20if (@ARGV)
21{
22    @extlist = @ARGV;
23
24	my $curexttype = "";
25	foreach my $ext (sort @extlist)
26	{
27		my ($extname, $exturl, $extstring, $reuse, $types, $tokens, $functions, $exacts) = parse_ext($ext);
28		my $exttype = $extname;
29		$exttype =~ s/(W?E?)GL(X?)_(.*?_)(.*)/$3/;
30		my $extrem = $extname;
31		$extrem =~ s/(W?E?)GL(X?)_(.*?_)(.*)/$4/;
32		my $extvar = $extname;
33		$extvar =~ s/(W?E?)GL(X?)_/$1GL$2EW_/;
34		if(!($exttype =~ $curexttype))
35		{
36			if(length($curexttype) > 0)
37			{
38				print "      }\n";
39			}
40			print "      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"$exttype\", " . length($exttype) . "))\n";
41			print "      {\n";
42			$curexttype = $exttype;
43		}
44		print "#ifdef $extname\n";
45		print "        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"$extrem\", ". length($extrem) . "))\n";
46		#print "        return $extvar;\n";
47		print "        {\n";
48		print "          ret = $extvar;\n";
49		print "          continue;\n";
50		print "        }\n";
51		print "#endif\n";
52	}
53
54	print "      }\n";
55}
56