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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
#!/usr/bin/env perl
# Author : Simos Xenitellis <simos at gnome dot org>.
# Authos : Bastien Nocera <hadess@hadess.net>
# Version : 1.2
#
# Notes : It downloads keysymdef.h from the Internet, if not found locally,
# Notes : and creates an updated clutter-keysyms.h
use strict;
my $update_url = 'http://git.clutter-project.org/clutter/plain/clutter/clutter-keysyms-update.pl';
# Used for reading the keysymdef symbols.
my @keysymelements;
my $keysymdef_url = 'http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h';
if ( ! -f "keysymdef.h" )
{
print "Trying to download keysymdef.h from\n", $keysymdef_url, "\n";
die "Unable to download keysymdef.h: $!"
unless system("wget -c -O keysymdef.h \"$keysymdef_url\"") == 0;
print " done.\n\n";
}
else
{
print "We are using existing keysymdef.h found in this directory.\n";
print "It is assumed that you took care and it is a recent version\n";
}
my $XF86keysym_url = 'http://cgit.freedesktop.org/xorg/proto/x11proto/plain/XF86keysym.h';
if ( ! -f "XF86keysym.h" )
{
print "Trying to download XF86keysym.h from\n", $XF86keysym_url, "\n";
die "Unable to download keysymdef.h: $!\n"
unless system("wget -c -O XF86keysym.h \"$XF86keysym_url\"") == 0;
print " done.\n\n";
}
else
{
print "We are using existing XF86keysym.h found in this directory.\n";
print "It is assumed that you took care and it is a recent version\n";
}
if ( -f "clutter-keysyms.h" )
{
print "There is already a clutter-keysyms.h file in this directory. We are not overwriting it.\n";
print "Please move it somewhere else in order to run this script.\n";
die "Exiting...\n\n";
}
die "Could not open file keysymdef.h: $!\n"
unless open(IN_KEYSYMDEF, "<:utf8", "keysymdef.h");
# Output: clutter/clutter/clutter-keysyms.h
die "Could not open file clutter-keysyms.h: $!\n"
unless open(OUT_KEYSYMS, ">:utf8", "clutter-keysyms.h");
# Output: clutter/clutter/deprecated/clutter-keysyms.h
die "Could not open file clutter-keysyms-compat.h: $!\n"
unless open(OUT_KEYSYMS_COMPAT, ">:utf8", "deprecated/clutter-keysyms.h");
my $LICENSE_HEADER= <<EOF;
/* Clutter
*
* Copyright (C) 2006, 2007, 2008 OpenedHand Ltd
* Copyright (C) 2009, 2010 Intel Corp
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses>.
*/
EOF
print OUT_KEYSYMS $LICENSE_HEADER;
print OUT_KEYSYMS_COMPAT $LICENSE_HEADER;
print OUT_KEYSYMS<<EOF;
/*
* File auto-generated from script at:
* $update_url
*
* using the input files:
* $keysymdef_url
* and
* $XF86keysym_url
*/
#ifndef __CLUTTER_KEYSYMS_H__
#define __CLUTTER_KEYSYMS_H__
EOF
print OUT_KEYSYMS_COMPAT<<EOF;
/*
* Compatibility version of clutter-keysyms.h.
*
* Since Clutter 1.4, the key symbol defines have been changed to have
* a KEY_ prefix. This is a compatibility header that is included when
* deprecated symbols are enabled. Consider porting to the new names
* instead.
*/
#ifndef __CLUTTER_KEYSYMS_DEPRECATED_H__
#define __CLUTTER_KEYSYMS_DEPRECATED_H__
#ifndef CLUTTER_DISABLE_DEPRECATED
EOF
while (<IN_KEYSYMDEF>)
{
next if ( ! /^#define / );
@keysymelements = split(/\s+/);
die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
$_ = $keysymelements[1];
die "Internal error, was expecting \"XC_*\", found: $_\n" if ( ! /^XK_/ );
$_ = $keysymelements[2];
die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
my $element = $keysymelements[1];
my $binding = $element;
$binding =~ s/^XK_/CLUTTER_KEY_/g;
my $compat_binding = $element;
$compat_binding =~ s/^XK_/CLUTTER_/g;
my $deprecation = "CLUTTER_DEPRECATED_MACRO_FOR(\"Deprecated key symbol. Use $binding instead.\")";
printf OUT_KEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
printf OUT_KEYSYMS_COMPAT "#define %s 0x%03x %s\n", $compat_binding, hex($keysymelements[2]), $deprecation;
}
close IN_KEYSYMDEF;
#$cluttersyms{"0"} = "0000";
# Source: http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=XF86keysym.h
die "Could not open file XF86keysym.h: $!\n" unless open(IN_XF86KEYSYM, "<:utf8", "XF86keysym.h");
while (<IN_XF86KEYSYM>)
{
next if ( ! /^#define / );
@keysymelements = split(/\s+/);
die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
$_ = $keysymelements[1];
die "Internal error, was expecting \"XF86XK_*\", found: $_\n" if ( ! /^XF86XK_/ );
# Work-around https://bugs.freedesktop.org/show_bug.cgi?id=11193
if ($_ eq "XF86XK_XF86BackForward") {
$keysymelements[1] = "XF86XK_AudioForward";
}
# XF86XK_Clear could end up a dupe of XK_Clear
# XF86XK_Select could end up a dupe of XK_Select
if ($_ eq "XF86XK_Clear") {
$keysymelements[1] = "XF86XK_WindowClear";
}
if ($_ eq "XF86XK_Select") {
$keysymelements[1] = "XF86XK_SelectButton";
}
# Ignore XF86XK_Q
next if ( $_ eq "XF86XK_Q");
# XF86XK_Calculater is misspelled, and a dupe
next if ( $_ eq "XF86XK_Calculater");
$_ = $keysymelements[2];
die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
my $element = $keysymelements[1];
my $binding = $element;
$binding =~ s/^XF86XK_/CLUTTER_KEY_/g;
my $compat_binding = $element;
$compat_binding =~ s/^XF86XK_/CLUTTER_/g;
printf OUT_KEYSYMS "#define %s 0x%03x\n", $binding, hex($keysymelements[2]);
printf OUT_KEYSYMS_COMPAT "#define %s 0x%03x\n", $compat_binding, hex($keysymelements[2]);
}
close IN_XF86KEYSYM;
print OUT_KEYSYMS<<EOF;
#endif /* __CLUTTER_KEYSYMS_H__ */
EOF
print OUT_KEYSYMS_COMPAT<<EOF;
#endif /* CLUTTER_DISABLE_DEPRECATED */
#endif /* __CLUTTER_KEYSYMS_DEPRECATED_H__ */
EOF
foreach my $f (qw/ keysymdef.h XF86keysym.h /) {
unlink $f or die "Unable to delete $f: $!";
}
printf "We just finished converting keysymdef.h to clutter-keysyms.h "
. "and deprecated/clutter-keysyms.h\nThank you\n";
|