X-Git-Url: http://git.demorecorder.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tools%2Fapi_conv.pl;h=2e6a1d0610ba6c5dc62d7ec82ae91035ea1f7157;hb=c912187f15c560c46768acb88aae30e67b0f78ce;hp=98402bf622339c2e210d978f9b259ec629f65481;hpb=06fba014435cfbdd1ff284d6d513d114503d02c2;p=free-sw%2Fxcb%2Flibxcb diff --git a/tools/api_conv.pl b/tools/api_conv.pl index 98402bf..2e6a1d0 100755 --- a/tools/api_conv.pl +++ b/tools/api_conv.pl @@ -1,6 +1,25 @@ #!/usr/bin/perl -plw use strict; +BEGIN { + %::const = map { $_ => 1 } ( + "XCBNone", + "XCBCopyFromParent", + "XCBCurrentTime", + "XCBNoSymbol", + "XCBError", + "XCBReply", + ); + open(CONST, shift) or die "failed to open constants list: $!"; + while() + { + chomp; + die "invalid constant name: \"$_\"" unless /^XCB[A-Za-z0-9_]*$/; + $::const{$_} = 1; + } + close(CONST); +} + sub convert($$) { local $_ = shift; @@ -10,6 +29,7 @@ sub convert($$) return "int$1_t" if /^INT(8|16|32)$/; return "uint8_t" if $_ eq 'BOOL' or $_ eq 'BYTE'; return $_ if /_/ or !/^XCB(.+)/; + my $const = defined $::const{$_}; $_ = $1; my %abbr = ( @@ -19,6 +39,9 @@ sub convert($$) ); s/[A-Z](?:[A-Z0-9]*|[a-z0-9]*)(?=[A-Z]|$)/"_" . ($abbr{$&} or lc($&))/eg; + + return "XCB" . uc($_) if $const; + $_ .= "_t" unless $fun; return "xcb" . $_;