Simplify the API conversion tool without functionality changes.
This commit is contained in:
parent
cdffbdd7ef
commit
bf41af718d
|
@ -1,41 +1,23 @@
|
||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
sub trans_lines($);
|
sub trans_lines();
|
||||||
|
|
||||||
my @xids=("WINDOW","VISUALTYPE","DRAWABLE","FONT","ATOM","COLORMAP","FONTABLE","GCONTEXT","PIXMAP","SCREEN");
|
my @xids=("WINDOW","VISUALTYPE","DRAWABLE","FONT","ATOM","COLORMAP","FONTABLE","GCONTEXT","PIXMAP","SCREEN");
|
||||||
|
|
||||||
my $input = $ARGV[0];
|
while(<>) {
|
||||||
|
|
||||||
open(INFILE,"<",$input) or die("Couldn't open file $input.\n");
|
trans_lines() unless (/#[a-z]/ or /print/ or /\/\// or /\/\*/);
|
||||||
|
print;
|
||||||
my @in_data = <INFILE>;
|
|
||||||
my @out_data;
|
|
||||||
|
|
||||||
foreach my $line (@in_data) {
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#################
|
#################
|
||||||
sub trans_lines($)
|
sub trans_lines()
|
||||||
{
|
{
|
||||||
my $line = $_[0];
|
s/XCB/xcb_/g;
|
||||||
|
|
||||||
$line =~ s/XCB/xcb_/g;
|
|
||||||
|
|
||||||
foreach my $xid (@xids) {
|
foreach my $xid (@xids) {
|
||||||
if($line =~ /$xid/ and $line =~ /xcb_/) {
|
if(/$xid/ and /xcb_/) {
|
||||||
my $lcxid = lc($xid);
|
my $lcxid = lc($xid);
|
||||||
|
|
||||||
#var
|
#var
|
||||||
|
@ -43,35 +25,28 @@ sub trans_lines($)
|
||||||
my $xidspun = $lcxid . "_t ";
|
my $xidspun = $lcxid . "_t ";
|
||||||
|
|
||||||
##
|
##
|
||||||
$line =~ s/$xid/$lcxid/g;
|
s/$xid/$lcxid/g;
|
||||||
|
|
||||||
#var
|
#var
|
||||||
$line =~ s/$xidsp/$xidspun/g;
|
s/$xidsp/$xidspun/g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#func without XID in it
|
#func without XID in it
|
||||||
my $funcline = $line;
|
if(/xcb_/) {
|
||||||
|
s/[A-Z]/"_" . lc($&)/eg;
|
||||||
|
s/__/_/g;
|
||||||
|
|
||||||
if($funcline =~ /xcb_/) {
|
if(/event/i) {
|
||||||
$funcline =~ s/[A-Z]/"_" . lc($&)/eg;
|
$_ = $` . "event" . "_t" . $';
|
||||||
$funcline =~ s/__/_/g;
|
|
||||||
|
|
||||||
if($funcline =~ /event/i) {
|
s/__/_/g;
|
||||||
$funcline =~ /event/i;
|
|
||||||
$funcline = $` . "event" . "_t" . $';
|
|
||||||
|
|
||||||
$funcline =~ s/__/_/g;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#repair NULL's
|
#repair NULL's
|
||||||
$funcline =~ s/_n_u_l_l/NULL/g;
|
s/_n_u_l_l/NULL/g;
|
||||||
#repair XCBSCREEN
|
#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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue