X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fsdl_const.pl;fp=scripts%2Fsdl_const.pl;h=88503ee4b027821901f814a47f5f8ee68dcaf0b8;hb=ee5feabd555deaa46d84a5e61e958f91e6cdef4b;hp=0000000000000000000000000000000000000000;hpb=084b921f85583af6a5b82572f6a561c94dd2fb5d;p=sdlgit%2FSDL_perl.git diff --git a/scripts/sdl_const.pl b/scripts/sdl_const.pl new file mode 100644 index 0000000..88503ee --- /dev/null +++ b/scripts/sdl_const.pl @@ -0,0 +1,115 @@ +#!/usr/bin/env perl +# + +open XS, "< sdl_words.txt" or die "could not open sdl_words.txt\n"; +open CPP, "| cpp `sdl-config --cflags` - > SDL.cx" or die "Could not pipe to cpp, $!\n"; + +print CPP < +#define TEXT_SOLID 1 +#define TEXT_SHADED 2 +#define TEXT_BLENDED 4 +#define UTF8_SOLID 8 +#define UTF8_SHADED 16 +#define UTF8_BLENDED 32 +#define UNICODE_SOLID 64 +#define UNICODE_SHADED 128 +#define UNICODE_BLENDED 256 + +--cut-- +HEADER + +while () { + chomp(); + print CPP "#$_ $_\n"; + $words{$_} = 0; +} + +close XS; +close CPP; + +# +# ENUMS AREN'T CPPed we got to do this the hard way +# + +open FP, "> sdl_const.c" or die "Could not write to sdl__const.c\n"; + +print FP < +#include +#include +#include +#include +#include +#define TEXT_SOLID 1 +#define TEXT_SHADED 2 +#define TEXT_BLENDED 4 +#define UTF8_SOLID 8 +#define UTF8_SHADED 16 +#define UTF8_BLENDED 32 +#define UNICODE_SOLID 64 +#define UNICODE_SHADED 128 +#define UNICODE_BLENDED 256 + +int +main ( int argc, char **argv ) { + +HERE + +for ( grep { $words{$_} == 0 } keys %words ) { + print FP <; +} +close ENUMS; + +$goodstuff .= "\n$enums"; + +for ( split "\n", $goodstuff ) { + if (/sub\s+main::([A-Za-z0-9_]+)/) { + $words{$1} = 1; + } +} + +for (keys %words) { + print STDERR "Failed to find $_\n" unless $words{$_}; +} + +(@words) = grep { $words{$_} == 1 } keys %words; + +$words = join(" ",@words); + +open CONST, "> ../lib/SDL/Constants.pm"; + +print CONST < +# + +package SDL::Constants; + +$goodstuff + +1; + +HERE + +system("rm -f SDL.cx sdl_const sdl_const.c");