[Xcb-commit] 2 commits - xcb

Jamey Sharp jamey at kemper.freedesktop.org
Thu Sep 14 00:05:14 PDT 2006


 xcb/tools/api_conv.pl |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+)

New commits:
diff-tree b214aac2ffdb35763a07d46ffd32cf5496688d50 (from 94b681b50bfd8a880310f6e3fceb3e31f9475ed3)
Author: Jamey Sharp <jamey at minilop.net>
Date:   Thu Sep 14 00:04:47 2006 -0700

    Simplify the API conversion tool without functionality changes.

diff --git a/xcb/tools/api_conv.pl b/xcb/tools/api_conv.pl
old mode 100644
new mode 100755
index 36f45ea..c7b97ee
--- a/xcb/tools/api_conv.pl
+++ b/xcb/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;
 }
 
diff-tree 94b681b50bfd8a880310f6e3fceb3e31f9475ed3 (from 5a88ac2a5ef9601c58b93f5d5c19f6aac303be85)
Author: Thomas Coppi <thisnukes4u at gmail.com>
Date:   Wed Sep 13 23:50:23 2006 -0700

    Prototype API conversion tool for upcoming lowercased XCB API.

diff --git a/xcb/tools/api_conv.pl b/xcb/tools/api_conv.pl
new file mode 100644
index 0000000..36f45ea
--- /dev/null
+++ b/xcb/tools/api_conv.pl
@@ -0,0 +1,77 @@
+#!/usr/bin/perl -w
+use strict;
+
+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) {
+	
+	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($)
+{
+	my $line = $_[0];
+	
+	$line =~ s/XCB/xcb_/g;	
+	
+	foreach my $xid (@xids) {
+		if($line =~ /$xid/ and $line =~ /xcb_/) {
+			my $lcxid = lc($xid);
+			
+			#var
+			my $xidsp = $lcxid . " ";
+			my $xidspun = $lcxid . "_t ";
+
+			##
+			$line =~ s/$xid/$lcxid/g;
+
+			#var
+			$line =~ s/$xidsp/$xidspun/g;
+		}
+	}
+
+	#func without XID in it
+	my $funcline = $line;
+
+	if($funcline =~ /xcb_/) {
+		$funcline =~ s/[A-Z]/"_" . lc($&)/eg;
+		$funcline =~ s/__/_/g;
+
+		if($funcline =~ /event/i) {
+			$funcline =~ /event/i;
+			$funcline = $` . "event" . "_t" . $';
+
+			$funcline =~ s/__/_/g;
+		}
+
+		#repair NULL's
+		$funcline =~ s/_n_u_l_l/NULL/g;
+		#repair XCBSCREEN
+		$funcline =~ s/s_c_r_e_e_n/screen/g;	
+	}
+
+	$line = $funcline;
+		
+	$out_data[@out_data] = $line;
+}
+


More information about the xcb-commit mailing list