3 # Converts a list of atoms in the form:
4 # // OUTPUT_CLASS=<classname>
5 # // MACRO_NAME=<macro>
6 # <macroname>(atomName, "String")
7 # <macroname>(atomName2, "String2")
9 # into a file suitable for gperf using static atoms
12 # make-atom-strings < file.h > file.gperf
14 # the lines in the C++ comments define two variables:
15 # OUTPUT_CLASS is the class who has all the atoms as members
16 # MACRO_NAME is the macro to look for in the rest of the file
19 # // OUTPUT_CLASS=nsHTMLAtoms
20 # // MACRO_NAME=HTML_ATOM
22 # HTML_ATOM(body, "body")
26 # this will generate a file that looks like:
27 # struct nsStaticAtom ( const char* mValue; nsIAtom** aAtom; }
29 # "a", &nsHTMLAtoms::a
30 # "body", &nsHTMLAtoms::body
34 # the output can be plugged into gperf to generate a perfect hash
36 print "struct nsStaticAtom {const char* mValue; nsIAtom** aAtom; };\n";
39 my $classname, $macroname;
43 if (/OUTPUT_CLASS=(\S+)/) {
45 } elsif (/MACRO_NAME=(\S+)/) {
48 elsif ($classname && $macroname &&
49 /$macroname\((\S+),\s*\"(.*?)\"\s*\)/) {
50 my ($str, $atom) = ($2, $1);
51 print "\"$str\", (nsIAtom**)&${classname}::$atom\n";