abecsi@webkit.org | aaed311 | 2010-06-13 13:54:07 +0000 | [diff] [blame] | 1 | #! /usr/bin/perl |
| 2 | # |
| 3 | # This file is part of the WebKit project |
| 4 | # |
| 5 | # Copyright (C) 2010 Andras Becsi (abecsi@inf.u-szeged.hu), University of Szeged |
| 6 | # |
| 7 | # This library is free software; you can redistribute it and/or |
| 8 | # modify it under the terms of the GNU Library General Public |
| 9 | # License as published by the Free Software Foundation; either |
| 10 | # version 2 of the License, or (at your option) any later version. |
| 11 | # |
| 12 | # This library is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | # Library General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU Library General Public License |
| 18 | # along with this library; see the file COPYING.LIB. If not, write to |
| 19 | # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | # Boston, MA 02110-1301, USA. |
| 21 | |
| 22 | use strict; |
| 23 | use Switch; |
| 24 | use File::Basename; |
| 25 | |
| 26 | my $outdir = $ARGV[0]; |
| 27 | shift; |
| 28 | my $option = basename($ARGV[0],".gperf"); |
| 29 | |
abecsi@webkit.org | c031b81 | 2010-09-28 16:01:47 +0000 | [diff] [blame] | 30 | my $hashToolsHeader = "$outdir/HashTools.h"; |
| 31 | |
| 32 | sub createHashToolsHeader() { |
| 33 | |
| 34 | open HEADER, ">$hashToolsHeader" || die "Could not open $hashToolsHeader for writing"; |
| 35 | print HEADER << "EOF"; |
| 36 | /* This file is automatically generated by make-hash-tools.pl, do not edit */ |
| 37 | |
| 38 | #ifndef HashTools_h |
| 39 | #define HashTools_h |
| 40 | |
| 41 | #include "wtf/Platform.h" |
| 42 | |
| 43 | namespace WebCore { |
| 44 | |
| 45 | struct PubIDInfo { |
| 46 | enum eMode { |
| 47 | eQuirks, |
| 48 | eQuirks3, |
| 49 | eAlmostStandards |
| 50 | }; |
| 51 | |
| 52 | const char* name; |
| 53 | eMode mode_if_no_sysid; |
| 54 | eMode mode_if_sysid; |
| 55 | }; |
| 56 | |
| 57 | struct NamedColor { |
| 58 | const char* name; |
jchaffraix@webkit.org | 69f48e0 | 2010-10-18 01:22:44 +0000 | [diff] [blame] | 59 | unsigned ARGBValue; |
abecsi@webkit.org | c031b81 | 2010-09-28 16:01:47 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | struct Property { |
| 63 | const char* name; |
| 64 | int id; |
| 65 | }; |
| 66 | |
| 67 | struct Value { |
| 68 | const char* name; |
| 69 | int id; |
| 70 | }; |
| 71 | |
| 72 | const PubIDInfo* findDoctypeEntry(register const char* str, register unsigned int len); |
| 73 | const NamedColor* findColor(register const char* str, register unsigned int len); |
| 74 | const Property* findProperty(register const char* str, register unsigned int len); |
| 75 | const Value* findValue(register const char* str, register unsigned int len); |
| 76 | } |
| 77 | |
| 78 | #endif // HashTools_h |
| 79 | |
| 80 | EOF |
| 81 | close HEADER; |
| 82 | |
| 83 | } |
| 84 | |
abecsi@webkit.org | aaed311 | 2010-06-13 13:54:07 +0000 | [diff] [blame] | 85 | switch ($option) { |
| 86 | |
abecsi@webkit.org | aaed311 | 2010-06-13 13:54:07 +0000 | [diff] [blame] | 87 | case "DocTypeStrings" { |
| 88 | |
abecsi@webkit.org | c031b81 | 2010-09-28 16:01:47 +0000 | [diff] [blame] | 89 | createHashToolsHeader(); |
| 90 | |
| 91 | my $docTypeStringsImpl = "$outdir/DocTypeStrings.cpp"; |
| 92 | my $docTypeStringsGenerated = "$outdir/DocTypeStringsHash.h"; |
abecsi@webkit.org | aaed311 | 2010-06-13 13:54:07 +0000 | [diff] [blame] | 93 | my $docTypeStringsGperf = $ARGV[0]; |
| 94 | shift; |
| 95 | |
abecsi@webkit.org | c031b81 | 2010-09-28 16:01:47 +0000 | [diff] [blame] | 96 | open DOCTYPESTRINGS, ">$docTypeStringsImpl" || die "Could not open $docTypeStringsImpl for writing"; |
| 97 | print DOCTYPESTRINGS << "EOF"; |
| 98 | /* This file is automatically generated by make-hash-tools.pl, do not edit */ |
| 99 | |
ossy@webkit.org | d142169 | 2010-09-28 21:35:54 +0000 | [diff] [blame] | 100 | #include <string.h> |
abecsi@webkit.org | c031b81 | 2010-09-28 16:01:47 +0000 | [diff] [blame] | 101 | #include "HashTools.h" |
| 102 | |
| 103 | namespace WebCore { |
| 104 | #include "DocTypeStringsHash.h" |
| 105 | |
| 106 | const PubIDInfo* findDoctypeEntry (register const char* str, register unsigned int len) |
| 107 | { |
| 108 | return DocTypeStringsHash::findDoctypeEntryImpl(str, len); |
| 109 | } |
| 110 | |
| 111 | } |
| 112 | |
| 113 | EOF |
| 114 | close DOCTYPESTRINGS; |
| 115 | |
abecsi@webkit.org | aaed311 | 2010-06-13 13:54:07 +0000 | [diff] [blame] | 116 | system("gperf --key-positions=\"*\" -s 2 $docTypeStringsGperf > $docTypeStringsGenerated") == 0 || die "calling gperf failed: $?"; |
| 117 | |
| 118 | } # case "DocTypeStrings" |
| 119 | |
| 120 | case "ColorData" { |
| 121 | |
abecsi@webkit.org | c031b81 | 2010-09-28 16:01:47 +0000 | [diff] [blame] | 122 | my $colorDataImpl = "$outdir/ColorData.cpp"; |
| 123 | my $colorDataGenerated = "$outdir/ColorDataHash.h"; |
| 124 | my $colorDataGperf = $ARGV[0]; |
abecsi@webkit.org | aaed311 | 2010-06-13 13:54:07 +0000 | [diff] [blame] | 125 | shift; |
| 126 | |
abecsi@webkit.org | c031b81 | 2010-09-28 16:01:47 +0000 | [diff] [blame] | 127 | open COLORDATA, ">$colorDataImpl" || die "Could not open $colorDataImpl for writing"; |
| 128 | print COLORDATA << "EOF"; |
| 129 | /* This file is automatically generated by make-hash-tools.pl, do not edit */ |
| 130 | |
ossy@webkit.org | d142169 | 2010-09-28 21:35:54 +0000 | [diff] [blame] | 131 | #include <string.h> |
abecsi@webkit.org | c031b81 | 2010-09-28 16:01:47 +0000 | [diff] [blame] | 132 | #include "HashTools.h" |
| 133 | |
| 134 | namespace WebCore { |
| 135 | #include "ColorDataHash.h" |
| 136 | |
| 137 | const struct NamedColor* findColor (register const char* str, register unsigned int len) |
| 138 | { |
| 139 | return ColorDataHash::findColorImpl(str, len); |
| 140 | } |
| 141 | |
| 142 | } |
| 143 | |
| 144 | EOF |
| 145 | close COLORDATA; |
| 146 | |
abecsi@webkit.org | aaed311 | 2010-06-13 13:54:07 +0000 | [diff] [blame] | 147 | system("gperf --key-positions=\"*\" -D -s 2 $colorDataGperf > $colorDataGenerated") == 0 || die "calling gperf failed: $?"; |
| 148 | |
| 149 | } # case "ColorData" |
| 150 | |
| 151 | } # switch ($option) |