Bumping manifests a=b2g-bump
[gecko.git] / config / make-atom-strings.pl
blob0ae804cf5895fcad6d4f7612ffeceeeda2014d30
1 #! perl
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Converts a list of atoms in the form:
8 # // OUTPUT_CLASS=<classname>
9 # // MACRO_NAME=<macro>
10 # <macroname>(atomName, "String")
11 # <macroname>(atomName2, "String2")
13 # into a file suitable for gperf using static atoms
15 # usage:
16 # make-atom-strings < file.h > file.gperf
18 # the lines in the C++ comments define two variables:
19 # OUTPUT_CLASS is the class who has all the atoms as members
20 # MACRO_NAME is the macro to look for in the rest of the file
22 # for example
23 # // OUTPUT_CLASS=nsHTMLAtoms
24 # // MACRO_NAME=HTML_ATOM
25 # HTML_ATOM(a, "a")
26 # HTML_ATOM(body, "body")
28 # etc...
30 # this will generate a file that looks like:
31 # struct nsStaticAtom ( const char* mValue; nsIAtom** aAtom; }
32 # %%
33 # "a", &nsHTMLAtoms::a
34 # "body", &nsHTMLAtoms::body
36 # etc...
38 # the output can be plugged into gperf to generate a perfect hash
40 print "struct nsStaticAtom {const char* mValue; nsIAtom** aAtom; };\n";
41 print "%%\n";
43 my $classname, $macroname;
45 while (<>) {
46 chop;
47 if (/OUTPUT_CLASS=(\S+)/) {
48 $classname=$1;
49 } elsif (/MACRO_NAME=(\S+)/) {
50 $macroname=$1;
52 elsif ($classname && $macroname &&
53 /$macroname\((\S+),\s*\"(.*?)\"\s*\)/) {
54 my ($str, $atom) = ($2, $1);
55 print "\"$str\", (nsIAtom**)&${classname}::$atom\n";