Handle names of constants during API conversion.
Use an XSLT stylesheet to get a list of all the constant names.
This commit is contained in:
parent
06fba01443
commit
c912187f15
|
@ -1,6 +1,25 @@
|
||||||
#!/usr/bin/perl -plw
|
#!/usr/bin/perl -plw
|
||||||
use strict;
|
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($$)
|
sub convert($$)
|
||||||
{
|
{
|
||||||
local $_ = shift;
|
local $_ = shift;
|
||||||
|
@ -10,6 +29,7 @@ sub convert($$)
|
||||||
return "int$1_t" if /^INT(8|16|32)$/;
|
return "int$1_t" if /^INT(8|16|32)$/;
|
||||||
return "uint8_t" if $_ eq 'BOOL' or $_ eq 'BYTE';
|
return "uint8_t" if $_ eq 'BOOL' or $_ eq 'BYTE';
|
||||||
return $_ if /_/ or !/^XCB(.+)/;
|
return $_ if /_/ or !/^XCB(.+)/;
|
||||||
|
my $const = defined $::const{$_};
|
||||||
$_ = $1;
|
$_ = $1;
|
||||||
|
|
||||||
my %abbr = (
|
my %abbr = (
|
||||||
|
@ -19,6 +39,9 @@ sub convert($$)
|
||||||
);
|
);
|
||||||
|
|
||||||
s/[A-Z](?:[A-Z0-9]*|[a-z0-9]*)(?=[A-Z]|$)/"_" . ($abbr{$&} or lc($&))/eg;
|
s/[A-Z](?:[A-Z0-9]*|[a-z0-9]*)(?=[A-Z]|$)/"_" . ($abbr{$&} or lc($&))/eg;
|
||||||
|
|
||||||
|
return "XCB" . uc($_) if $const;
|
||||||
|
|
||||||
$_ .= "_t" unless $fun;
|
$_ .= "_t" unless $fun;
|
||||||
|
|
||||||
return "xcb" . $_;
|
return "xcb" . $_;
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue