PageRenderTime 42ms CodeModel.GetById 33ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/scripts/gl_const.pl

http://github.com/PerlGameDev/SDL
Perl | 69 lines | 51 code | 11 blank | 7 comment | 1 complexity | 1a31b3348c2698260e496b503ce75d7e MD5 | raw file
 1#!/usr/bin/env perl
 2#
 3
 4open XS,  "< opengl_words.txt";
 5open CPP, "| cpp - > OpenGL.cx";
 6
 7print CPP <<HEADER;
 8#include <GL/gl.h>
 9#include <GL/glu.h>
10
11--cut--
12HEADER
13
14while (<XS>) {
15	chomp();
16	print CPP "#$_ $_\n";
17	$words{$_} = 0;
18}
19
20close XS;
21close CPP;
22
23my $text;
24open FP, "< OpenGL.cx"
25	or die "Couldn't open OpenGL.cx\n";
26{
27	local $/ = undef;
28	$text = <FP>;
29}
30
31my ( $junk, $goodstuff ) = split "--cut--", $text;
32
33$goodstuff =~ s/#(GL[U]?_[A-Z0-9_]+)\s+([0-9xa-fA-F]+)/sub main::$1 { $2 }/g;
34
35for ( split "\n", $goodstuff ) {
36	if (/sub main::(GL[U]?_[A-Z0-9_]+)/) {
37		push @words, $1;
38	}
39}
40
41for (@words) {
42	$words{$_} = 1;
43}
44
45for ( keys %words ) {
46	print STDERR "Failed to find word $_" unless ( $words{$_} );
47}
48
49open OGL, "> ../lib/SDL/OpenGL/Constants.pm";
50
51$words = join( " ", @words );
52
53print OGL <<HERE;
54# SDL::OpenGL::Constants
55#
56# This is an autogenerate file, don't bother editing.
57# Names are read from a list in opengl_words.txt and written by gl_const.pl.
58#
59# Copyright (C) 2003 David J. Goehrig <dave\@sdlperl.org>
60
61package SDL::OpenGL::Constants;
62
63$goodstuff
64
651;
66
67HERE
68
69system("rm OpenGL.cx");