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.
27 open NAMES, "<CSSValueKeywords.in" || die "Could not open CSSValueKeywords.in";
30 next if (m/(^#)|(^\s*$)/);
31 # Input may use a different EOL sequence than $/, so avoid chomp.
37 open GPERF, ">CSSValueKeywords.gperf" || die "Could not open CSSValueKeywords.gperf for writing";
40 /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */
42 #include \"CSSValueKeywords.h\"
52 %define lookup-function-name findValue
53 %define hash-function-name value_hash_function
54 %define word-array-name value_word_list
60 foreach my $name (@names) {
62 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
63 print GPERF $name . ", CSSValue" . $id . "\n";
68 open HEADER, ">CSSValueKeywords.h" || die "Could not open CSSValueKeywords.h for writing";
69 print HEADER << "EOF";
70 /* This file is automatically generated from CSSValueKeywords.in by makevalues, do not edit */
72 #ifndef CSSValueKeywords_h
73 #define CSSValueKeywords_h
75 const int CSSValueInvalid = 0;
80 foreach my $name (@names) {
82 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
83 print HEADER "const int CSSValue" . $id . " = " . $i . ";\n";
85 if (length($name) > $maxLen) {
86 $maxLen = length($name);
89 print HEADER "const int numCSSValueKeywords = " . $i . ";\n";
90 print HEADER "const size_t maxCSSValueKeywordLength = " . $maxLen . ";\n";
91 print HEADER << "EOF";
93 const char* getValueName(unsigned short id);
95 #endif // CSSValueKeywords_h
99 system("gperf --key-positions=\"*\" -D -n -s 2 CSSValueKeywords.gperf > CSSValueKeywords.cpp") == 0 || die "calling gperf failed: $?";
101 open C, ">>CSSValueKeywords.cpp" || die "Could not open CSSValueKeywords.cpp for writing";
102 print C "static const char * const valueList[] = {\n";
104 foreach my $name (@names) {
105 print C "\"" . $name . "\", \n";
110 const char* getValueName(unsigned short id)
112 if (id >= numCSSValueKeywords || id <= 0)
114 return valueList[id];