3 # This file is part of the WebKit project
5 # Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
6 # Copyright (C) 2007, 2012 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);
44 # Input may use a different EOL sequence than $/, so avoid chomp.
46 # CSS values need to be lower case.
48 if (exists $namesHash{$_}) {
56 if (@duplicates > 0) {
57 die 'Duplicate CSS value keywords values: ', join(', ', @duplicates) . "\n";
60 open GPERF, ">CSSValueKeywords.gperf" || die "Could not open CSSValueKeywords.gperf for writing";
63 /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */
65 #include \"CSSValueKeywords.h\"
66 #include \"HashTools.h\"
77 %define class-name CSSValueKeywordsHash
78 %define lookup-function-name findValueImpl
79 %define hash-function-name value_hash_function
80 %define word-array-name value_word_list
85 foreach my $name (@names) {
87 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
88 print GPERF $name . ", CSSValue" . $id . "\n";
93 static const char* const valueList[] = {
97 foreach my $name (@names) {
98 print GPERF " \"" . $name . "\",\n";
101 print GPERF << "EOF";
105 const Value* findValue(register const char* str, register unsigned int len)
107 return CSSValueKeywordsHash::findValueImpl(str, len);
110 const char* getValueName(unsigned short id)
112 if (id >= numCSSValueKeywords || id <= 0)
114 return valueList[id];
117 } // namespace WebCore
122 open HEADER, ">CSSValueKeywords.h" || die "Could not open CSSValueKeywords.h for writing";
123 print HEADER << "EOF";
124 /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */
126 #ifndef CSSValueKeywords_h
127 #define CSSValueKeywords_h
139 foreach my $name (@names) {
141 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
142 print HEADER " CSSValue" . $id . " = " . $i . ",\n";
144 if (length($name) > $maxLen) {
145 $maxLen = length($name);
149 print HEADER "};\n\n";
150 print HEADER "const int numCSSValueKeywords = " . $i . ";\n";
151 print HEADER "const size_t maxCSSValueKeywordLength = " . $maxLen . ";\n";
152 print HEADER << "EOF";
154 const char* getValueName(unsigned short id);
156 } // namespace WebCore
158 #endif // CSSValueKeywords_h
163 my $gperf = $ENV{GPERF} ? $ENV{GPERF} : "gperf";
164 system("\"$gperf\" --key-positions=\"*\" -D -n -s 2 CSSValueKeywords.gperf --output-file=CSSValueKeywords.cpp") == 0 || die "calling gperf failed: $?";