summaryrefslogtreecommitdiff
path: root/tools/api_conv.pl
blob: c7b97eee9ec45913155c0dac13868dc29ea3551a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl -w
use strict;

sub trans_lines();

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;	
	
	foreach my $xid (@xids) {
		if(/$xid/ and /xcb_/) {
			my $lcxid = lc($xid);
			
			#var
			my $xidsp = $lcxid . " ";
			my $xidspun = $lcxid . "_t ";

			##
			s/$xid/$lcxid/g;

			#var
			s/$xidsp/$xidspun/g;
		}
	}

	#func without XID in it
	if(/xcb_/) {
		s/[A-Z]/"_" . lc($&)/eg;
		s/__/_/g;

		if(/event/i) {
			$_ = $` . "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;	
	}
}