From: Tobias Leich Date: Wed, 11 Nov 2009 19:12:34 +0000 (+0100) Subject: regex for #define X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f14bf6bb1d0a59f94ba3fc5346466a77a63d3419;p=sdlgit%2FSDL_perl.git regex for #define --- diff --git a/scripts/auto_constants.pl b/scripts/auto_constants.pl index a8f958b..84dd2e9 100644 --- a/scripts/auto_constants.pl +++ b/scripts/auto_constants.pl @@ -3,24 +3,28 @@ use strict; use warnings; my $head_loc = `sdl-config --cflags`; - $head_loc = (split ' ', $head_loc)[0]; - $head_loc =~ s/-I//; -print 'Getting header constants from '.$head_loc."\n"; + $head_loc = (split ' ', $head_loc)[0]; + $head_loc =~ s/-I//; +print "# Getting header constants from $head_loc\n"; -my @header = qw/ SDL.h /; +my @header = qw/ SDL.h SDL_events.h /; foreach (@header) { - open FH, $head_loc.'/'.$_; - while() - { - if ($_ =~ /#define SDL_/) - { - my $line = $_; - my @cop = (split ' ', $line); - print 'sub '.$cop[1].' {return '.$cop[2].'}'."\n" ; - } - } - close FH; + print "# from $_:\n"; + open FH, "$head_loc/$_"; + while() + { + if($_ =~ /#define SDL_/) + { + my $line = $_; + my @cop = (split ' ', $line); + print 'sub '.$cop[1].' {return '.$cop[2].'}'."\n" ; + } + + # pattern: "#define SDL_RELEASED 0" + printf("sub %s{ return %s; }\n", $1, $2) if($_ =~ /^#define\s+(\w+)\s+(\w+)\s*$/); + } + close FH; }