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)
8 # Copyright (C) 2010 Andras Becsi (abecsi@inf.u-szeged.hu), University of Szeged
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Library General Public
12 # License as published by the Free Software Foundation; either
13 # version 2 of the License, or (at your option) any later version.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Library General Public License for more details.
20 # You should have received a copy of the GNU Library General Public License
21 # along with this library; see the file COPYING.LIB. If not, write to
22 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 # Boston, MA 02110-1301, USA.
31 GetOptions('defines=s' => \$defines,
32 'preprocessor=s' => \$preprocessor);
34 my @NAMES = applyPreprocessor("CSSValueKeywords.in", $defines, $preprocessor);
42 # Input may use a different EOL sequence than $/, so avoid chomp.
44 # CSS values need to be lower case.
46 if (exists $namesHash{$_}) {
54 if (@duplicates > 0) {
55 die 'Duplicate CSS value keywords values: ', join(', ', @duplicates) . "\n";
58 open GPERF, ">CSSValueKeywords.gperf" || die "Could not open CSSValueKeywords.gperf for writing";
61 /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */
63 #include \"CSSValueKeywords.h\"
64 #include \"HashTools.h\"
75 %define class-name CSSValueKeywordsHash
76 %define lookup-function-name findValueImpl
77 %define hash-function-name value_hash_function
78 %define word-array-name value_word_list
83 foreach my $name (@names) {
85 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
86 print GPERF $name . ", CSSValue" . $id . "\n";
91 static const char* const valueList[] = {
95 foreach my $name (@names) {
96 print GPERF " \"" . $name . "\",\n";
103 const Value* findValue(register const char* str, register unsigned int len)
105 return CSSValueKeywordsHash::findValueImpl(str, len);
108 const char* getValueName(unsigned short id)
110 if (id >= numCSSValueKeywords || id <= 0)
112 return valueList[id];
115 } // namespace WebCore
120 open HEADER, ">CSSValueKeywords.h" || die "Could not open CSSValueKeywords.h for writing";
121 print HEADER << "EOF";
122 /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */
124 #ifndef CSSValueKeywords_h
125 #define CSSValueKeywords_h
131 const int CSSValueInvalid = 0;
136 foreach my $name (@names) {
138 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
139 print HEADER "const int CSSValue" . $id . " = " . $i . ";\n";
141 if (length($name) > $maxLen) {
142 $maxLen = length($name);
145 print HEADER "const int numCSSValueKeywords = " . $i . ";\n";
146 print HEADER "const size_t maxCSSValueKeywordLength = " . $maxLen . ";\n";
147 print HEADER << "EOF";
149 const char* getValueName(unsigned short id);
151 } // namespace WebCore
153 #endif // CSSValueKeywords_h
158 system("gperf --key-positions=\"*\" -D -n -s 2 CSSValueKeywords.gperf > CSSValueKeywords.cpp") == 0 || die "calling gperf failed: $?";