3 # This file is part of the WebKit project
5 # Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
6 # Copyright (C) 2007, 2008 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("CSSPropertyNames.in", $defines, $preprocessor);
43 # Input may use a different EOL sequence than $/, so avoid chomp.
45 if (exists $namesHash{$_}) {
57 if (@duplicates > 0) {
58 die 'Duplicate CSS property names: ', join(', ', @duplicates) . "\n";
61 open GPERF, ">CSSPropertyNames.gperf" || die "Could not open CSSPropertyNames.gperf for writing";
64 /* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */
65 #include \"CSSPropertyNames.h\"
66 #include \"HashTools.h\"
78 %define class-name CSSPropertyNamesHash
79 %define lookup-function-name findPropertyImpl
80 %define hash-function-name propery_hash_function
81 %define word-array-name property_wordlist
86 foreach my $name (@names) {
88 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
89 print GPERF $name . ", CSSProperty" . $id . "\n";
92 foreach my $alias (@aliases) {
93 $alias =~ /^([^\s]*)[\s]*=[\s]*([^\s]*)/;
96 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
97 print GPERF $name . ", CSSProperty" . $id . "\n";
102 const Property* findProperty(register const char* str, register unsigned int len)
104 return CSSPropertyNamesHash::findPropertyImpl(str, len);
107 const char* getPropertyName(CSSPropertyID id)
109 if (id < firstCSSProperty)
111 int index = id - firstCSSProperty;
112 if (index >= numCSSProperties)
114 return propertyNameStrings[index];
117 } // namespace WebCore
120 open HEADER, ">CSSPropertyNames.h" || die "Could not open CSSPropertyNames.h for writing";
121 print HEADER << "EOF";
122 /* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */
124 #ifndef CSSPropertyNames_h
125 #define CSSPropertyNames_h
132 CSSPropertyInvalid = 0,
138 foreach my $name (@names) {
140 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
141 print HEADER " CSSProperty" . $id . " = " . $i . ",\n";
143 if (length($name) > $maxLen) {
144 $maxLen = length($name);
147 my $num = $i - $first;
149 print HEADER "};\n\n";
150 print HEADER "const int firstCSSProperty = $first;\n";
151 print HEADER "const int numCSSProperties = $num;\n";
152 print HEADER "const size_t maxCSSPropertyNameLength = $maxLen;\n";
154 print HEADER "const char* const propertyNameStrings[$num] = {\n";
155 foreach my $name (@names) {
156 print HEADER "\"$name\",\n";
160 print HEADER << "EOF";
162 const char* getPropertyName(CSSPropertyID);
164 } // namespace WebCore
166 #endif // CSSPropertyNames_h
172 system("gperf --key-positions=\"*\" -D -n -s 2 CSSPropertyNames.gperf > CSSPropertyNames.cpp") == 0 || die "calling gperf failed: $?";