~ubuntu-branches/ubuntu/trusty/glew/trusty

« back to all changes in this revision

Viewing changes to auto/bin/make_header.pl

  • Committer: Bazaar Package Importer
  • Author(s): Joost Yervante Damad
  • Date: 2010-04-10 18:16:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100410181621-179fn0er7sjbccku
Tags: 1.5.3-1
* New upstream release (Closes: #577183)
* reworked mx build support to reflect new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
##
3
 
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
4
 
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
5
 
##
6
 
## This program is distributed under the terms and conditions of the GNU
7
 
## General Public License Version 2 as published by the Free Software
8
 
## Foundation or, at your option, any later version.
9
 
 
10
 
use strict;
11
 
use warnings;
12
 
 
13
 
do 'bin/make.pl';
14
 
 
15
 
# token
16
 
sub make_define($$)
17
 
{
18
 
    return "#define $_[0] $_[1]"
19
 
}
20
 
 
21
 
# type declaration
22
 
sub make_type($$)
23
 
{
24
 
    return "typedef $_[1] $_[0];"
25
 
}
26
 
 
27
 
# function pointer type declaration
28
 
sub make_pfn_type($%)
29
 
{
30
 
    our $api;
31
 
    return join(' ', "typedef", $_[1]->{rtype},
32
 
        "($api * PFN" . (uc $_[0]) . "PROC)",
33
 
        "(" . $_[1]->{parms} . ")") . ";";
34
 
}
35
 
 
36
 
# function name alias
37
 
sub make_pfn_alias($%)
38
 
{
39
 
    our $type;
40
 
    return join(" ", "#define", $_[0], $type . "EW_GET_FUN(" . prefixname($_[0]) . ")")
41
 
}
42
 
 
43
 
my @extlist = ();
44
 
my %extensions = ();
45
 
 
46
 
our $api = shift;
47
 
our $type = shift;
48
 
 
49
 
if (@ARGV)
50
 
{
51
 
    @extlist = @ARGV;
52
 
 
53
 
        foreach my $ext (sort @extlist)
54
 
        {
55
 
                my ($extname, $exturl, $types, $tokens, $functions, $exacts) = parse_ext($ext);
56
 
 
57
 
                make_separator($extname);
58
 
                print "#ifndef $extname\n#define $extname 1\n";
59
 
                output_tokens($tokens, \&make_define);
60
 
                output_types($types, \&make_type);
61
 
                output_exacts($exacts, \&make_exact);
62
 
                output_decls($functions, \&make_pfn_type);
63
 
                output_decls($functions, \&make_pfn_alias);
64
 
 
65
 
                my $extvar = $extname;
66
 
                $extvar =~ s/GL(X*)_/GL$1EW_/;
67
 
                
68
 
                print "\n#define $extvar " . $type . "EW_GET_VAR(" . prefix_varname($extvar) . ")\n";
69
 
                print "\n#endif /* $extname */\n\n";
70
 
        }
71
 
}
 
1
#!/usr/bin/perl
 
2
##
 
3
## Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
 
4
## Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
 
5
##
 
6
## This program is distributed under the terms and conditions of the GNU
 
7
## General Public License Version 2 as published by the Free Software
 
8
## Foundation or, at your option, any later version.
 
9
 
 
10
use strict;
 
11
use warnings;
 
12
 
 
13
do 'bin/make.pl';
 
14
 
 
15
# token
 
16
sub make_define($$)
 
17
{
 
18
    return "#define $_[0] $_[1]"
 
19
}
 
20
 
 
21
# type declaration
 
22
sub make_type($$)
 
23
{
 
24
    return "typedef $_[1] $_[0];"
 
25
}
 
26
 
 
27
# function pointer type declaration
 
28
sub make_pfn_type($%)
 
29
{
 
30
    our $api;
 
31
    return join(' ', "typedef", $_[1]->{rtype},
 
32
        "($api * PFN" . (uc $_[0]) . "PROC)",
 
33
        "(" . $_[1]->{parms} . ")") . ";";
 
34
}
 
35
 
 
36
# function name alias
 
37
sub make_pfn_alias($%)
 
38
{
 
39
    our $type;
 
40
    return join(" ", "#define", $_[0], $type . "EW_GET_FUN(" . prefixname($_[0]) . ")")
 
41
}
 
42
 
 
43
my @extlist = ();
 
44
my %extensions = ();
 
45
 
 
46
our $api = shift;
 
47
our $type = shift;
 
48
 
 
49
if (@ARGV)
 
50
{
 
51
    @extlist = @ARGV;
 
52
 
 
53
        foreach my $ext (sort @extlist)
 
54
        {
 
55
                my ($extname, $exturl, $types, $tokens, $functions, $exacts) = parse_ext($ext);
 
56
 
 
57
                make_separator($extname);
 
58
                print "#ifndef $extname\n#define $extname 1\n";
 
59
                output_tokens($tokens, \&make_define);
 
60
                output_types($types, \&make_type);
 
61
                output_exacts($exacts, \&make_exact);
 
62
                output_decls($functions, \&make_pfn_type);
 
63
                output_decls($functions, \&make_pfn_alias);
 
64
 
 
65
                my $extvar = $extname;
 
66
                $extvar =~ s/GL(X*)_/GL$1EW_/;
 
67
                
 
68
                print "\n#define $extvar " . $type . "EW_GET_VAR(" . prefix_varname($extvar) . ")\n";
 
69
                print "\n#endif /* $extname */\n\n";
 
70
        }
 
71
}