3 # This file is part of the WebKit project
5 # Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
6 # Copyright (C) 2007 Apple Inc. All rights reserved.
7 # Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Library General Public
11 # License as published by the Free Software Foundation; either
12 # version 2 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Library General Public License for more details.
19 # You should have received a copy of the GNU Library General Public License
20 # along with this library; see the file COPYING.LIB. If not, write to
21 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 # Boston, MA 02110-1301, USA.
26 open NAMES, "<CSSValueKeywords.in" || die "Could not open CSSValueKeywords.in";
29 next if (m/(^#)|(^\s*$)/);
30 # Input may use a different EOL sequence than $/, so avoid chomp.
36 open GPERF, ">CSSValueKeywords.gperf" || die "Could not open CSSValueKeywords.gperf for writing";
39 /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */
41 #include \"CSSValueKeywords.h\"
50 foreach my $name (@names) {
52 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
53 print GPERF $name . ", CSSValue" . $id . "\n";
58 open HEADER, ">CSSValueKeywords.h" || die "Could not open CSSValueKeywords.h for writing";
59 print HEADER << "EOF";
60 /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */
65 const int CSSValueInvalid = 0;
70 foreach my $name (@names) {
72 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
73 print HEADER "const int CSSValue" . $id . " = " . $i . ";\n";
75 if (length($name) > $maxLen) {
76 $maxLen = length($name);
79 print HEADER "const int numCSSValueKeywords = " . $i . ";\n";
80 print HEADER "const size_t maxCSSValueKeywordLength = " . $maxLen . ";\n";
81 print HEADER << "EOF";
83 const char* getValueName(unsigned short id);
89 system("gperf -L ANSI-C -E -C -n -o -t --key-positions=\"*\" -NfindValue -Hhash_val -Wwordlist_value -D CSSValueKeywords.gperf > CSSValueKeywords.c");
91 open C, ">>CSSValueKeywords.c" || die "Could not open CSSValueKeywords.c for writing";
92 print C "static const char * const valueList[] = {\n";
94 foreach my $name (@names) {
95 print C "\"" . $name . "\", \n";
100 const char* getValueName(unsigned short id)
102 if (id >= numCSSValueKeywords || id <= 0)
104 return valueList[id];