Complete rewrite of api_conv.pl.
Now handles all API changes except constant names, which are treated like type names.
This commit is contained in:
parent
bf41af718d
commit
06fba01443
|
@ -1,52 +1,27 @@
|
||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -plw
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
sub trans_lines();
|
sub convert($$)
|
||||||
|
|
||||||
my @xids=("WINDOW","VISUALTYPE","DRAWABLE","FONT","ATOM","COLORMAP","FONTABLE","GCONTEXT","PIXMAP","SCREEN");
|
|
||||||
|
|
||||||
while(<>) {
|
|
||||||
|
|
||||||
trans_lines() unless (/#[a-z]/ or /print/ or /\/\// or /\/\*/);
|
|
||||||
print;
|
|
||||||
}
|
|
||||||
|
|
||||||
#################
|
|
||||||
sub trans_lines()
|
|
||||||
{
|
{
|
||||||
s/XCB/xcb_/g;
|
local $_ = shift;
|
||||||
|
my ($fun) = @_;
|
||||||
foreach my $xid (@xids) {
|
|
||||||
if(/$xid/ and /xcb_/) {
|
|
||||||
my $lcxid = lc($xid);
|
|
||||||
|
|
||||||
#var
|
|
||||||
my $xidsp = $lcxid . " ";
|
|
||||||
my $xidspun = $lcxid . "_t ";
|
|
||||||
|
|
||||||
##
|
return "uint$1_t" if /^CARD(8|16|32)$/;
|
||||||
s/$xid/$lcxid/g;
|
return "int$1_t" if /^INT(8|16|32)$/;
|
||||||
|
return "uint8_t" if $_ eq 'BOOL' or $_ eq 'BYTE';
|
||||||
|
return $_ if /_/ or !/^XCB(.+)/;
|
||||||
|
$_ = $1;
|
||||||
|
|
||||||
#var
|
my %abbr = (
|
||||||
s/$xidsp/$xidspun/g;
|
"Iter" => "iterator",
|
||||||
}
|
"Req" => "request",
|
||||||
}
|
"Rep" => "reply",
|
||||||
|
);
|
||||||
|
|
||||||
#func without XID in it
|
s/[A-Z](?:[A-Z0-9]*|[a-z0-9]*)(?=[A-Z]|$)/"_" . ($abbr{$&} or lc($&))/eg;
|
||||||
if(/xcb_/) {
|
$_ .= "_t" unless $fun;
|
||||||
s/[A-Z]/"_" . lc($&)/eg;
|
|
||||||
s/__/_/g;
|
|
||||||
|
|
||||||
if(/event/i) {
|
return "xcb" . $_;
|
||||||
$_ = $` . "event" . "_t" . $';
|
|
||||||
|
|
||||||
s/__/_/g;
|
|
||||||
}
|
|
||||||
|
|
||||||
#repair NULL's
|
|
||||||
s/_n_u_l_l/NULL/g;
|
|
||||||
#repair XCBSCREEN
|
|
||||||
s/s_c_r_e_e_n/screen/g;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s/([_A-Za-z][_A-Za-z0-9]*)([ \t]*\()?/convert($1, defined $2) . ($2 or "")/eg;
|
||||||
|
|
Loading…
Reference in New Issue