[Xcb-commit] 2 commits - xcb
Jamey Sharp
jamey at kemper.freedesktop.org
Mon Sep 18 00:28:40 PDT 2006
xcb/tools/api_conv.pl | 86 ++++++++++++++++++++++------------------------
xcb/tools/const-names.xsl | 21 +++++++++++
2 files changed, 63 insertions(+), 44 deletions(-)
New commits:
diff-tree e29500b5c1748dbdb214d137df8de629dfd3f49a (from f3aeaa9db6b13f213385f618d5193d95227ee20a)
Author: Jamey Sharp <jamey at minilop.net>
Date: Mon Sep 18 00:25:26 2006 -0700
Handle names of constants during API conversion.
Use an XSLT stylesheet to get a list of all the constant names.
diff --git a/xcb/tools/api_conv.pl b/xcb/tools/api_conv.pl
index 98402bf..2e6a1d0 100755
--- a/xcb/tools/api_conv.pl
+++ b/xcb/tools/api_conv.pl
@@ -1,6 +1,25 @@
#!/usr/bin/perl -plw
use strict;
+BEGIN {
+ %::const = map { $_ => 1 } (
+ "XCBNone",
+ "XCBCopyFromParent",
+ "XCBCurrentTime",
+ "XCBNoSymbol",
+ "XCBError",
+ "XCBReply",
+ );
+ open(CONST, shift) or die "failed to open constants list: $!";
+ while(<CONST>)
+ {
+ chomp;
+ die "invalid constant name: \"$_\"" unless /^XCB[A-Za-z0-9_]*$/;
+ $::const{$_} = 1;
+ }
+ close(CONST);
+}
+
sub convert($$)
{
local $_ = shift;
@@ -10,6 +29,7 @@ sub convert($$)
return "int$1_t" if /^INT(8|16|32)$/;
return "uint8_t" if $_ eq 'BOOL' or $_ eq 'BYTE';
return $_ if /_/ or !/^XCB(.+)/;
+ my $const = defined $::const{$_};
$_ = $1;
my %abbr = (
@@ -19,6 +39,9 @@ sub convert($$)
);
s/[A-Z](?:[A-Z0-9]*|[a-z0-9]*)(?=[A-Z]|$)/"_" . ($abbr{$&} or lc($&))/eg;
+
+ return "XCB" . uc($_) if $const;
+
$_ .= "_t" unless $fun;
return "xcb" . $_;
diff --git a/xcb/tools/const-names.xsl b/xcb/tools/const-names.xsl
new file mode 100644
index 0000000..5cff33e
--- /dev/null
+++ b/xcb/tools/const-names.xsl
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+ <xsl:output method="text"/>
+
+ <xsl:strip-space elements="*"/>
+
+ <xsl:variable name="nl"><xsl:text>
+</xsl:text></xsl:variable>
+
+ <xsl:template match="enum/item">
+ <xsl:value-of select="concat('XCB', /xcb/@extension-name, ../@name, @name, $nl)"/>
+ </xsl:template>
+
+ <xsl:template match="event|eventcopy|error|errorcopy">
+ <xsl:value-of select="concat('XCB', /xcb/@extension-name, @name, $nl)"/>
+ </xsl:template>
+
+ <xsl:template match="text()"/>
+
+</xsl:transform>
diff-tree f3aeaa9db6b13f213385f618d5193d95227ee20a (from b214aac2ffdb35763a07d46ffd32cf5496688d50)
Author: Jamey Sharp <jamey at minilop.net>
Date: Sun Sep 17 23:38:57 2006 -0700
Complete rewrite of api_conv.pl.
Now handles all API changes except constant names, which are treated like type names.
diff --git a/xcb/tools/api_conv.pl b/xcb/tools/api_conv.pl
index c7b97ee..98402bf 100755
--- a/xcb/tools/api_conv.pl
+++ b/xcb/tools/api_conv.pl
@@ -1,52 +1,27 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -plw
use strict;
-sub trans_lines();
+sub convert($$)
+{
+ local $_ = shift;
+ my ($fun) = @_;
-my @xids=("WINDOW","VISUALTYPE","DRAWABLE","FONT","ATOM","COLORMAP","FONTABLE","GCONTEXT","PIXMAP","SCREEN");
+ return "uint$1_t" if /^CARD(8|16|32)$/;
+ return "int$1_t" if /^INT(8|16|32)$/;
+ return "uint8_t" if $_ eq 'BOOL' or $_ eq 'BYTE';
+ return $_ if /_/ or !/^XCB(.+)/;
+ $_ = $1;
+
+ my %abbr = (
+ "Iter" => "iterator",
+ "Req" => "request",
+ "Rep" => "reply",
+ );
-while(<>) {
-
- trans_lines() unless (/#[a-z]/ or /print/ or /\/\// or /\/\*/);
- print;
-}
+ s/[A-Z](?:[A-Z0-9]*|[a-z0-9]*)(?=[A-Z]|$)/"_" . ($abbr{$&} or lc($&))/eg;
+ $_ .= "_t" unless $fun;
-#################
-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;
- }
+ return "xcb" . $_;
}
+s/([_A-Za-z][_A-Za-z0-9]*)([ \t]*\()?/convert($1, defined $2) . ($2 or "")/eg;
More information about the xcb-commit
mailing list