X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fgl_const.pl;fp=scripts%2Fgl_const.pl;h=af9592220961ef4bbd067e0537ae6bb7bbd43476;hb=ee5feabd555deaa46d84a5e61e958f91e6cdef4b;hp=0000000000000000000000000000000000000000;hpb=084b921f85583af6a5b82572f6a561c94dd2fb5d;p=sdlgit%2FSDL_perl.git diff --git a/scripts/gl_const.pl b/scripts/gl_const.pl new file mode 100644 index 0000000..af95922 --- /dev/null +++ b/scripts/gl_const.pl @@ -0,0 +1,69 @@ +#!/usr/bin/env perl +# + +open XS, "< opengl_words.txt"; +open CPP, "| cpp - > OpenGL.cx"; + +print CPP < +#include + +--cut-- +HEADER + +while () { + chomp(); + print CPP "#$_ $_\n"; + $words{$_} = 0; +} + +close XS; +close CPP; + +my $text; +open FP, "< OpenGL.cx" + or die "Couldn't open OpenGL.cx\n"; +{ + local $/ = undef; + $text = ; +} + +my ($junk,$goodstuff) = split "--cut--", $text; + +$goodstuff =~ s/#(GL[U]?_[A-Z0-9_]+)\s+([0-9xa-fA-F]+)/sub main::$1 { $2 }/g; + +for (split "\n",$goodstuff) { + if (/sub main::(GL[U]?_[A-Z0-9_]+)/ ) { + push @words, $1; + } +} + +for ( @words ) { + $words{$_} = 1; +} + +for ( keys %words ) { + print STDERR "Failed to find word $_" unless ($words{$_}); +} + +open OGL, "> ../lib/SDL/OpenGL/Constants.pm"; + +$words = join(" ",@words); + +print OGL < + +package SDL::OpenGL::Constants; + +$goodstuff + +1; + +HERE + +system("rm OpenGL.cx");