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.
27 open NAMES, "<CSSPropertyNames.in" || die "Could not find CSSPropertyNames.in";
30 next if (m/(^#)|(^\s*$)/);
31 # Input may use a different EOL sequence than $/, so avoid chomp.
37 open GPERF, ">CSSPropertyNames.gperf" || die "Could not open CSSPropertyNames.gperf for writing";
40 /* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */
41 #include \"CSSPropertyNames.h\"
52 %define lookup-function-name findProperty
53 %define hash-function-name propery_hash_function
54 %define word-array-name property_wordlist
60 foreach my $name (@names) {
62 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
63 print GPERF $name . ", CSSProperty" . $id . "\n";
68 open HEADER, ">CSSPropertyNames.h" || die "Could not open CSSPropertyNames.h for writing";
69 print HEADER << "EOF";
70 /* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */
72 #ifndef CSSPropertyNames_h
73 #define CSSPropertyNames_h
76 CSSPropertyInvalid = 0,
82 foreach my $name (@names) {
84 $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
85 print HEADER " CSSProperty" . $id . " = " . $i . ",\n";
87 if (length($name) > $maxLen) {
88 $maxLen = length($name);
91 my $num = $i - $first;
93 print HEADER "};\n\n";
94 print HEADER "const int firstCSSProperty = $first;\n";
95 print HEADER "const int numCSSProperties = $num;\n";
96 print HEADER "const size_t maxCSSPropertyNameLength = $maxLen;\n";
98 print HEADER << "EOF";
100 const char* getPropertyName(CSSPropertyID);
102 #endif // CSSPropertyNames_h
108 system("gperf --key-positions=\"*\" -D -n -s 2 CSSPropertyNames.gperf > CSSPropertyNames.cpp") == 0 || die "calling gperf failed: $?";
110 open C, ">>CSSPropertyNames.cpp" || die "Could not open CSSPropertyNames.cpp for writing";
111 print C "static const char * const propertyNameStrings[$num] = {\n";
113 foreach my $name (@names) {
114 print C "\"$name\",\n";
119 const char* getPropertyName(CSSPropertyID id)
121 if (id < firstCSSProperty)
123 int index = id - firstCSSProperty;
124 if (index >= numCSSProperties)
126 return propertyNameStrings[index];