blob: b070829a5ff27e0a667e13385fd00db7d10b07f7 [file] [log] [blame]
abecsi@webkit.orgaaed3112010-06-13 13:54:07 +00001#! /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
22use strict;
23use Switch;
24use File::Basename;
25
26my $outdir = $ARGV[0];
27shift;
28my $option = basename($ARGV[0],".gperf");
29
abecsi@webkit.orgc031b812010-09-28 16:01:47 +000030my $hashToolsHeader = "$outdir/HashTools.h";
31
32sub createHashToolsHeader() {
33
34open HEADER, ">$hashToolsHeader" || die "Could not open $hashToolsHeader for writing";
35print 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
43namespace WebCore {
44
45struct 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
57struct NamedColor {
58 const char* name;
jchaffraix@webkit.org69f48e02010-10-18 01:22:44 +000059 unsigned ARGBValue;
abecsi@webkit.orgc031b812010-09-28 16:01:47 +000060};
61
62struct Property {
63 const char* name;
64 int id;
65};
66
67struct Value {
68 const char* name;
69 int id;
70};
71
72const PubIDInfo* findDoctypeEntry(register const char* str, register unsigned int len);
73const NamedColor* findColor(register const char* str, register unsigned int len);
74const Property* findProperty(register const char* str, register unsigned int len);
75const Value* findValue(register const char* str, register unsigned int len);
76}
77
78#endif // HashTools_h
79
80EOF
81close HEADER;
82
83}
84
abecsi@webkit.orgaaed3112010-06-13 13:54:07 +000085switch ($option) {
86
abecsi@webkit.orgaaed3112010-06-13 13:54:07 +000087case "DocTypeStrings" {
88
abecsi@webkit.orgc031b812010-09-28 16:01:47 +000089 createHashToolsHeader();
90
91 my $docTypeStringsImpl = "$outdir/DocTypeStrings.cpp";
92 my $docTypeStringsGenerated = "$outdir/DocTypeStringsHash.h";
abecsi@webkit.orgaaed3112010-06-13 13:54:07 +000093 my $docTypeStringsGperf = $ARGV[0];
94 shift;
95
abecsi@webkit.orgc031b812010-09-28 16:01:47 +000096 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.orgd1421692010-09-28 21:35:54 +0000100#include <string.h>
abecsi@webkit.orgc031b812010-09-28 16:01:47 +0000101#include "HashTools.h"
102
103namespace WebCore {
104#include "DocTypeStringsHash.h"
105
106const PubIDInfo* findDoctypeEntry (register const char* str, register unsigned int len)
107{
108 return DocTypeStringsHash::findDoctypeEntryImpl(str, len);
109}
110
111}
112
113EOF
114 close DOCTYPESTRINGS;
115
abecsi@webkit.orgaaed3112010-06-13 13:54:07 +0000116 system("gperf --key-positions=\"*\" -s 2 $docTypeStringsGperf > $docTypeStringsGenerated") == 0 || die "calling gperf failed: $?";
117
118} # case "DocTypeStrings"
119
120case "ColorData" {
121
abecsi@webkit.orgc031b812010-09-28 16:01:47 +0000122 my $colorDataImpl = "$outdir/ColorData.cpp";
123 my $colorDataGenerated = "$outdir/ColorDataHash.h";
124 my $colorDataGperf = $ARGV[0];
abecsi@webkit.orgaaed3112010-06-13 13:54:07 +0000125 shift;
126
abecsi@webkit.orgc031b812010-09-28 16:01:47 +0000127 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.orgd1421692010-09-28 21:35:54 +0000131#include <string.h>
abecsi@webkit.orgc031b812010-09-28 16:01:47 +0000132#include "HashTools.h"
133
134namespace WebCore {
135#include "ColorDataHash.h"
136
137const struct NamedColor* findColor (register const char* str, register unsigned int len)
138{
139 return ColorDataHash::findColorImpl(str, len);
140}
141
142}
143
144EOF
145 close COLORDATA;
146
abecsi@webkit.orgaaed3112010-06-13 13:54:07 +0000147 system("gperf --key-positions=\"*\" -D -s 2 $colorDataGperf > $colorDataGenerated") == 0 || die "calling gperf failed: $?";
148
149} # case "ColorData"
150
151} # switch ($option)