summaryrefslogtreecommitdiff
path: root/tools/api_conv.pl
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2006-09-14 00:04:47 -0700
committerJamey Sharp <jamey@minilop.net>2006-09-14 00:04:47 -0700
commitbf41af718d6a83532d1c2f63ac16e6484e8e8b68 (patch)
tree9b53426e156ee050d5a9e4da42d387f225928968 /tools/api_conv.pl
parentcdffbdd7ef9dee58b3c36ca46bb88aa187b46526 (diff)
Simplify the API conversion tool without functionality changes.
Diffstat (limited to 'tools/api_conv.pl')
-rwxr-xr-x[-rw-r--r--]tools/api_conv.pl59
1 files changed, 17 insertions, 42 deletions
diff --git a/tools/api_conv.pl b/tools/api_conv.pl
index 36f45ea..c7b97ee 100644..100755
--- a/tools/api_conv.pl
+++ b/tools/api_conv.pl
@@ -1,41 +1,23 @@
#!/usr/bin/perl -w
use strict;
-sub trans_lines($);
+sub trans_lines();
my @xids=("WINDOW","VISUALTYPE","DRAWABLE","FONT","ATOM","COLORMAP","FONTABLE","GCONTEXT","PIXMAP","SCREEN");
-my $input = $ARGV[0];
-
-open(INFILE,"<",$input) or die("Couldn't open file $input.\n");
-
-my @in_data = <INFILE>;
-my @out_data;
-
-foreach my $line (@in_data) {
+while(<>) {
- if($line =~ /#[a-z]/ or $line =~ /print/ or $line =~ /\/\// or $line =~ /\/\*/) {
- $out_data[@out_data] = $line;
- next;
- }
-
- trans_lines($line);
-}
-
-
-foreach my $newline (@out_data) {
- print $newline;
+ trans_lines() unless (/#[a-z]/ or /print/ or /\/\// or /\/\*/);
+ print;
}
#################
-sub trans_lines($)
+sub trans_lines()
{
- my $line = $_[0];
-
- $line =~ s/XCB/xcb_/g;
+ s/XCB/xcb_/g;
foreach my $xid (@xids) {
- if($line =~ /$xid/ and $line =~ /xcb_/) {
+ if(/$xid/ and /xcb_/) {
my $lcxid = lc($xid);
#var
@@ -43,35 +25,28 @@ sub trans_lines($)
my $xidspun = $lcxid . "_t ";
##
- $line =~ s/$xid/$lcxid/g;
+ s/$xid/$lcxid/g;
#var
- $line =~ s/$xidsp/$xidspun/g;
+ s/$xidsp/$xidspun/g;
}
}
#func without XID in it
- my $funcline = $line;
+ if(/xcb_/) {
+ s/[A-Z]/"_" . lc($&)/eg;
+ s/__/_/g;
- if($funcline =~ /xcb_/) {
- $funcline =~ s/[A-Z]/"_" . lc($&)/eg;
- $funcline =~ s/__/_/g;
+ if(/event/i) {
+ $_ = $` . "event" . "_t" . $';
- if($funcline =~ /event/i) {
- $funcline =~ /event/i;
- $funcline = $` . "event" . "_t" . $';
-
- $funcline =~ s/__/_/g;
+ s/__/_/g;
}
#repair NULL's
- $funcline =~ s/_n_u_l_l/NULL/g;
+ s/_n_u_l_l/NULL/g;
#repair XCBSCREEN
- $funcline =~ s/s_c_r_e_e_n/screen/g;
+ s/s_c_r_e_e_n/screen/g;
}
-
- $line = $funcline;
-
- $out_data[@out_data] = $line;
}