This commit is contained in:
kipp 1998-07-03 17:19:58 +00:00
Родитель 89072e57d5
Коммит ffe1d07336
6 изменённых файлов: 840 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Do not edit - generated by gentags.pl */
#include <string.h>
#include "nsHTMLTags.h"
static char* tagTable[] = {
"A", "ABBR", "ACRONYM", "ADDRESS", "APPLET", "AREA", "B", "BASE",
"BASEFONT", "BDO", "BIG", "BLINK", "BLOCKQUOTE", "BODY", "BR", "BUTTON",
"CAPTION", "CENTER", "CITE", "CODE", "COL", "COLGROUP", "DD", "DEL", "DFN",
"DIR", "DIV", "DL", "DT", "EM", "EMBED", "FIELDSET", "FONT", "FORM",
"FRAME", "FRAMESET", "H1", "H2", "H3", "H4", "H5", "H6", "HEAD", "HR",
"HTML", "I", "IFRAME", "ILAYER", "IMG", "INPUT", "INS", "ISINDEX", "KBD",
"KEYGEN", "LABEL", "LAYER", "LEGEND", "LI", "LINK", "LISTING", "MAP",
"MENU", "META", "MULTICOL", "NOBR", "NOEMBED", "NOFRAMES", "NOLAYER",
"NOSCRIPT", "OBJECT", "OL", "OPTGROUP", "OPTION", "P", "PARAM",
"PLAINTEXT", "PRE", "Q", "S", "SAMP", "SCRIPT", "SELECT", "SERVER",
"SMALL", "SPACER", "SPAN", "STRIKE", "STRONG", "STYLE", "SUB", "SUP",
"TABLE", "TBODY", "TD", "TEXTAREA", "TFOOT", "TH", "THEAD", "TITLE", "TR",
"TT", "U", "UL", "VAR", "WBR", "XMP"
};
nsHTMLTag NS_TagToEnum(const char* aTagName) {
int low = 0;
int high = NS_HTML_TAG_MAX - 1;
while (low <= high) {
int middle = (low + high) >> 1;
int result = strcmp(aTagName, tagTable[middle]);
if (result == 0)
return (nsHTMLTag) middle;
if (result < 0)
high = middle - 1;
else
low = middle + 1;
}
return eHTMLTag_userdefined;
}
const char* NS_EnumToTag(nsHTMLTag aTagID) {
if ((unsigned int)aTagID > NS_HTML_TAG_MAX) {
return 0;
}
return tagTable[(int) aTagID];
}

Просмотреть файл

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Do not edit - generated by gentags.pl */
#ifndef nsHTMLTags_h___
#define nsHTMLTags_h___
#include "nshtmlpars.h"
enum nsHTMLTag {
eHTMLTag_a=0, eHTMLTag_abbr=1, eHTMLTag_acronym=2, eHTMLTag_address=3,
eHTMLTag_applet=4, eHTMLTag_area=5, eHTMLTag_b=6, eHTMLTag_base=7,
eHTMLTag_basefont=8, eHTMLTag_bdo=9, eHTMLTag_big=10, eHTMLTag_blink=11,
eHTMLTag_blockquote=12, eHTMLTag_body=13, eHTMLTag_br=14,
eHTMLTag_button=15, eHTMLTag_caption=16, eHTMLTag_center=17,
eHTMLTag_cite=18, eHTMLTag_code=19, eHTMLTag_col=20, eHTMLTag_colgroup=21,
eHTMLTag_dd=22, eHTMLTag_del=23, eHTMLTag_dfn=24, eHTMLTag_dir=25,
eHTMLTag_div=26, eHTMLTag_dl=27, eHTMLTag_dt=28, eHTMLTag_em=29,
eHTMLTag_embed=30, eHTMLTag_fieldset=31, eHTMLTag_font=32,
eHTMLTag_form=33, eHTMLTag_frame=34, eHTMLTag_frameset=35, eHTMLTag_h1=36,
eHTMLTag_h2=37, eHTMLTag_h3=38, eHTMLTag_h4=39, eHTMLTag_h5=40,
eHTMLTag_h6=41, eHTMLTag_head=42, eHTMLTag_hr=43, eHTMLTag_html=44,
eHTMLTag_i=45, eHTMLTag_iframe=46, eHTMLTag_ilayer=47, eHTMLTag_img=48,
eHTMLTag_input=49, eHTMLTag_ins=50, eHTMLTag_isindex=51, eHTMLTag_kbd=52,
eHTMLTag_keygen=53, eHTMLTag_label=54, eHTMLTag_layer=55,
eHTMLTag_legend=56, eHTMLTag_li=57, eHTMLTag_link=58, eHTMLTag_listing=59,
eHTMLTag_map=60, eHTMLTag_menu=61, eHTMLTag_meta=62, eHTMLTag_multicol=63,
eHTMLTag_nobr=64, eHTMLTag_noembed=65, eHTMLTag_noframes=66,
eHTMLTag_nolayer=67, eHTMLTag_noscript=68, eHTMLTag_object=69,
eHTMLTag_ol=70, eHTMLTag_optgroup=71, eHTMLTag_option=72, eHTMLTag_p=73,
eHTMLTag_param=74, eHTMLTag_plaintext=75, eHTMLTag_pre=76, eHTMLTag_q=77,
eHTMLTag_s=78, eHTMLTag_samp=79, eHTMLTag_script=80, eHTMLTag_select=81,
eHTMLTag_server=82, eHTMLTag_small=83, eHTMLTag_spacer=84,
eHTMLTag_span=85, eHTMLTag_strike=86, eHTMLTag_strong=87,
eHTMLTag_style=88, eHTMLTag_sub=89, eHTMLTag_sup=90, eHTMLTag_table=91,
eHTMLTag_tbody=92, eHTMLTag_td=93, eHTMLTag_textarea=94, eHTMLTag_tfoot=95,
eHTMLTag_th=96, eHTMLTag_thead=97, eHTMLTag_title=98, eHTMLTag_tr=99,
eHTMLTag_tt=100, eHTMLTag_u=101, eHTMLTag_ul=102, eHTMLTag_var=103,
eHTMLTag_wbr=104, eHTMLTag_xmp=105,
/* The remaining enums are not for tags */
eHTMLTag_text=106, eHTMLTag_whitespace=107, eHTMLTag_newline=108,
eHTMLTag_comment=109, eHTMLTag_entity=110, eHTMLTag_userdefined=111,
eHTMLTag_unknown=112, eHTMLTag_secret_h1style=113,
eHTMLTag_secret_h2style=114, eHTMLTag_secret_h3style=115,
eHTMLTag_secret_h4style=116, eHTMLTag_secret_h5style=117,
eHTMLTag_secret_h6style=118
};
#define NS_HTML_TAG_MAX 106
extern NS_HTMLPARS nsHTMLTag NS_TagToEnum(const char* aTag);
extern NS_HTMLPARS const char* NS_EnumToTag(nsHTMLTag aEnum);
#endif /* nsHTMLTags_h___ */

292
htmlparser/tools/gentags.pl Normal file
Просмотреть файл

@ -0,0 +1,292 @@
#! /usr/local/bin/perl
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
######################################################################
# Table of tag names; it doesn't have to be sorted because code
# below will do it. However, for the sake of ease of additions, keep
# it sorted so that its easy to tell where to add a new tag and that
# the tag hasn't already been added.
$i = 0;
$tags[$i++] = "a";
$tags[$i++] = "abbr";
$tags[$i++] = "acronym";
$tags[$i++] = "address";
$tags[$i++] = "applet";
$tags[$i++] = "area";
$tags[$i++] = "b";
$tags[$i++] = "base";
$tags[$i++] = "basefont";
$tags[$i++] = "bdo";
$tags[$i++] = "big";
$tags[$i++] = "blink";
$tags[$i++] = "blockquote";
$tags[$i++] = "body";
$tags[$i++] = "br";
$tags[$i++] = "button";
$tags[$i++] = "caption";
$tags[$i++] = "center";
$tags[$i++] = "cite";
$tags[$i++] = "code";
$tags[$i++] = "col";
$tags[$i++] = "colgroup";
$tags[$i++] = "dd";
$tags[$i++] = "del";
$tags[$i++] = "dfn";
$tags[$i++] = "dir";
$tags[$i++] = "div";
$tags[$i++] = "dl";
$tags[$i++] = "dt";
$tags[$i++] = "em";
$tags[$i++] = "embed";
$tags[$i++] = "fieldset";
$tags[$i++] = "font";
$tags[$i++] = "form";
$tags[$i++] = "frame";
$tags[$i++] = "frameset";
$tags[$i++] = "h1";
$tags[$i++] = "h2";
$tags[$i++] = "h3";
$tags[$i++] = "h4";
$tags[$i++] = "h5";
$tags[$i++] = "h6";
$tags[$i++] = "head";
$tags[$i++] = "hr";
$tags[$i++] = "html";
$tags[$i++] = "i";
$tags[$i++] = "iframe";
$tags[$i++] = "ilayer";
$tags[$i++] = "img";
$tags[$i++] = "input";
$tags[$i++] = "ins";
$tags[$i++] = "isindex";
$tags[$i++] = "kbd";
$tags[$i++] = "keygen";
$tags[$i++] = "label";
$tags[$i++] = "layer";
$tags[$i++] = "legend";
$tags[$i++] = "li";
$tags[$i++] = "link";
$tags[$i++] = "listing";
$tags[$i++] = "map";
$tags[$i++] = "menu";
$tags[$i++] = "meta";
$tags[$i++] = "multicol";
$tags[$i++] = "nobr";
$tags[$i++] = "noembed";
$tags[$i++] = "noframes";
$tags[$i++] = "nolayer";
$tags[$i++] = "noscript";
$tags[$i++] = "object";
$tags[$i++] = "ol";
$tags[$i++] = "optgroup";
$tags[$i++] = "option";
$tags[$i++] = "p";
$tags[$i++] = "param";
$tags[$i++] = "plaintext";
$tags[$i++] = "pre";
$tags[$i++] = "q";
$tags[$i++] = "s";
$tags[$i++] = "samp";
$tags[$i++] = "script";
$tags[$i++] = "select";
$tags[$i++] = "server";
$tags[$i++] = "small";
$tags[$i++] = "spacer";
$tags[$i++] = "span";
$tags[$i++] = "strike";
$tags[$i++] = "strong";
$tags[$i++] = "style";
$tags[$i++] = "sub";
$tags[$i++] = "sup";
$tags[$i++] = "table";
$tags[$i++] = "tbody";
$tags[$i++] = "td";
$tags[$i++] = "textarea";
$tags[$i++] = "tfoot";
$tags[$i++] = "th";
$tags[$i++] = "thead";
$tags[$i++] = "title";
$tags[$i++] = "tr";
$tags[$i++] = "tt";
$tags[$i++] = "u";
$tags[$i++] = "ul";
$tags[$i++] = "var";
$tags[$i++] = "wbr";
$tags[$i++] = "xmp";
######################################################################
# These are not tags; rather they are extra values to place into the
# tag enumeration after the normal tags. These do not need to be sorted
# and they do not go into the tag table, just into the tag enumeration.
$extra = 0;
$extra_tags[$extra++] = "text";
$extra_tags[$extra++] = "whitespace";
$extra_tags[$extra++] = "newline";
$extra_tags[$extra++] = "comment";
$extra_tags[$extra++] = "entity";
$extra_tags[$extra++] = "userdefined";
$extra_tags[$extra++] = "unknown";
$extra_tags[$extra++] = "secret_h1style";
$extra_tags[$extra++] = "secret_h2style";
$extra_tags[$extra++] = "secret_h3style";
$extra_tags[$extra++] = "secret_h4style";
$extra_tags[$extra++] = "secret_h5style";
$extra_tags[$extra++] = "secret_h6style";
######################################################################
# Sort the tag table before using it
@tags = sort @tags;
$copyright = "/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the \"License\"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an \"AS IS\"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Do not edit - generated by gentags.pl */
";
######################################################################
$file_base = @ARGV[0];
# Generate the header file first
open(HEADER_FILE, ">$file_base.h");
# Print out copyright and do not edit notice
print HEADER_FILE $copyright;
print HEADER_FILE "#ifndef " . $file_base . "_h___\n";
print HEADER_FILE "#define " . $file_base . "_h___\n";
print HEADER_FILE "#include \"nshtmlpars.h\"\n";
# Print out enum's for the tag symbols
print HEADER_FILE "enum nsHTMLTag {\n ";
$width = 2;
for ($j = 0; $j < $i; $j++) {
$lower = $tags[$j];
$lower =~ tr/A-Z/a-z/;
$str = "eHTMLTag_" . $lower . "=" . $j;
$str = $str . ", ";
$len = length($str);
if ($width + $len > 78) {
print HEADER_FILE "\n ";
$width = 2;
}
print HEADER_FILE $str;
$width = $width + $len;
}
print HEADER_FILE "\n\n /* The remaining enums are not for tags */\n ";
# Print out extra enum's that are not in the tag table
$width = 2;
for ($k = 0; $k < $extra; $k++) {
$lower = $extra_tags[$k];
$lower =~ tr/A-Z/a-z/;
$str = "eHTMLTag_" . $lower . "=" . ($j + $k);
if ($k < $extra - 1) {
$str = $str . ", ";
}
$len = length($str);
if ($width + $len > 78) {
print HEADER_FILE "\n ";
$width = 2;
}
print HEADER_FILE $str;
$width = $width + $len;
}
print HEADER_FILE "\n};\n#define NS_HTML_TAG_MAX " . $j . "\n\n";
print HEADER_FILE
"extern NS_HTMLPARS nsHTMLTag NS_TagToEnum(const char* aTag);\n";
print HEADER_FILE
"extern NS_HTMLPARS const char* NS_EnumToTag(nsHTMLTag aEnum);\n";
print HEADER_FILE "#endif /* " . $file_base . "_h___ */\n";
close(HEADER_FILE);
######################################################################
# Generate the source file
open(CPP_FILE, ">$file_base.cpp");
print CPP_FILE $copyright;
print CPP_FILE "#include <string.h>\n";
print CPP_FILE "#include \"$file_base.h\"\n\n";
# Print out table of tag names
print CPP_FILE "static char* tagTable[] = {\n ";
$width = 2;
for ($j = 0; $j < $i; $j++) {
$upper = $tags[$j];
$upper =~ tr/a-z/A-Z/;
$str = "\"" . $upper . "\"";
if ($j < $i - 1) {
$str = $str . ", ";
}
$len = length($str);
if ($width + $len > 78) {
print CPP_FILE "\n ";
$width = 2;
}
print CPP_FILE $str;
$width = $width + $len;
}
print CPP_FILE "\n};\n";
# Finally, dump out the search routine that takes a char* and finds it
# in the table.
print CPP_FILE "
nsHTMLTag NS_TagToEnum(const char* aTagName) {
int low = 0;
int high = NS_HTML_TAG_MAX - 1;
while (low <= high) {
int middle = (low + high) >> 1;
int result = strcmp(aTagName, tagTable[middle]);
if (result == 0)
return (nsHTMLTag) middle;
if (result < 0)
high = middle - 1;
else
low = middle + 1;
}
return eHTMLTag_userdefined;
}
const char* NS_EnumToTag(nsHTMLTag aTagID) {
if ((unsigned int)aTagID > NS_HTML_TAG_MAX) {
return 0;
}
return tagTable[(int) aTagID];
}
";
close(CPP_FILE);

Просмотреть файл

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Do not edit - generated by gentags.pl */
#include <string.h>
#include "nsHTMLTags.h"
static char* tagTable[] = {
"A", "ABBR", "ACRONYM", "ADDRESS", "APPLET", "AREA", "B", "BASE",
"BASEFONT", "BDO", "BIG", "BLINK", "BLOCKQUOTE", "BODY", "BR", "BUTTON",
"CAPTION", "CENTER", "CITE", "CODE", "COL", "COLGROUP", "DD", "DEL", "DFN",
"DIR", "DIV", "DL", "DT", "EM", "EMBED", "FIELDSET", "FONT", "FORM",
"FRAME", "FRAMESET", "H1", "H2", "H3", "H4", "H5", "H6", "HEAD", "HR",
"HTML", "I", "IFRAME", "ILAYER", "IMG", "INPUT", "INS", "ISINDEX", "KBD",
"KEYGEN", "LABEL", "LAYER", "LEGEND", "LI", "LINK", "LISTING", "MAP",
"MENU", "META", "MULTICOL", "NOBR", "NOEMBED", "NOFRAMES", "NOLAYER",
"NOSCRIPT", "OBJECT", "OL", "OPTGROUP", "OPTION", "P", "PARAM",
"PLAINTEXT", "PRE", "Q", "S", "SAMP", "SCRIPT", "SELECT", "SERVER",
"SMALL", "SPACER", "SPAN", "STRIKE", "STRONG", "STYLE", "SUB", "SUP",
"TABLE", "TBODY", "TD", "TEXTAREA", "TFOOT", "TH", "THEAD", "TITLE", "TR",
"TT", "U", "UL", "VAR", "WBR", "XMP"
};
nsHTMLTag NS_TagToEnum(const char* aTagName) {
int low = 0;
int high = NS_HTML_TAG_MAX - 1;
while (low <= high) {
int middle = (low + high) >> 1;
int result = strcmp(aTagName, tagTable[middle]);
if (result == 0)
return (nsHTMLTag) middle;
if (result < 0)
high = middle - 1;
else
low = middle + 1;
}
return eHTMLTag_userdefined;
}
const char* NS_EnumToTag(nsHTMLTag aTagID) {
if ((unsigned int)aTagID > NS_HTML_TAG_MAX) {
return 0;
}
return tagTable[(int) aTagID];
}

Просмотреть файл

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Do not edit - generated by gentags.pl */
#ifndef nsHTMLTags_h___
#define nsHTMLTags_h___
#include "nshtmlpars.h"
enum nsHTMLTag {
eHTMLTag_a=0, eHTMLTag_abbr=1, eHTMLTag_acronym=2, eHTMLTag_address=3,
eHTMLTag_applet=4, eHTMLTag_area=5, eHTMLTag_b=6, eHTMLTag_base=7,
eHTMLTag_basefont=8, eHTMLTag_bdo=9, eHTMLTag_big=10, eHTMLTag_blink=11,
eHTMLTag_blockquote=12, eHTMLTag_body=13, eHTMLTag_br=14,
eHTMLTag_button=15, eHTMLTag_caption=16, eHTMLTag_center=17,
eHTMLTag_cite=18, eHTMLTag_code=19, eHTMLTag_col=20, eHTMLTag_colgroup=21,
eHTMLTag_dd=22, eHTMLTag_del=23, eHTMLTag_dfn=24, eHTMLTag_dir=25,
eHTMLTag_div=26, eHTMLTag_dl=27, eHTMLTag_dt=28, eHTMLTag_em=29,
eHTMLTag_embed=30, eHTMLTag_fieldset=31, eHTMLTag_font=32,
eHTMLTag_form=33, eHTMLTag_frame=34, eHTMLTag_frameset=35, eHTMLTag_h1=36,
eHTMLTag_h2=37, eHTMLTag_h3=38, eHTMLTag_h4=39, eHTMLTag_h5=40,
eHTMLTag_h6=41, eHTMLTag_head=42, eHTMLTag_hr=43, eHTMLTag_html=44,
eHTMLTag_i=45, eHTMLTag_iframe=46, eHTMLTag_ilayer=47, eHTMLTag_img=48,
eHTMLTag_input=49, eHTMLTag_ins=50, eHTMLTag_isindex=51, eHTMLTag_kbd=52,
eHTMLTag_keygen=53, eHTMLTag_label=54, eHTMLTag_layer=55,
eHTMLTag_legend=56, eHTMLTag_li=57, eHTMLTag_link=58, eHTMLTag_listing=59,
eHTMLTag_map=60, eHTMLTag_menu=61, eHTMLTag_meta=62, eHTMLTag_multicol=63,
eHTMLTag_nobr=64, eHTMLTag_noembed=65, eHTMLTag_noframes=66,
eHTMLTag_nolayer=67, eHTMLTag_noscript=68, eHTMLTag_object=69,
eHTMLTag_ol=70, eHTMLTag_optgroup=71, eHTMLTag_option=72, eHTMLTag_p=73,
eHTMLTag_param=74, eHTMLTag_plaintext=75, eHTMLTag_pre=76, eHTMLTag_q=77,
eHTMLTag_s=78, eHTMLTag_samp=79, eHTMLTag_script=80, eHTMLTag_select=81,
eHTMLTag_server=82, eHTMLTag_small=83, eHTMLTag_spacer=84,
eHTMLTag_span=85, eHTMLTag_strike=86, eHTMLTag_strong=87,
eHTMLTag_style=88, eHTMLTag_sub=89, eHTMLTag_sup=90, eHTMLTag_table=91,
eHTMLTag_tbody=92, eHTMLTag_td=93, eHTMLTag_textarea=94, eHTMLTag_tfoot=95,
eHTMLTag_th=96, eHTMLTag_thead=97, eHTMLTag_title=98, eHTMLTag_tr=99,
eHTMLTag_tt=100, eHTMLTag_u=101, eHTMLTag_ul=102, eHTMLTag_var=103,
eHTMLTag_wbr=104, eHTMLTag_xmp=105,
/* The remaining enums are not for tags */
eHTMLTag_text=106, eHTMLTag_whitespace=107, eHTMLTag_newline=108,
eHTMLTag_comment=109, eHTMLTag_entity=110, eHTMLTag_userdefined=111,
eHTMLTag_unknown=112, eHTMLTag_secret_h1style=113,
eHTMLTag_secret_h2style=114, eHTMLTag_secret_h3style=115,
eHTMLTag_secret_h4style=116, eHTMLTag_secret_h5style=117,
eHTMLTag_secret_h6style=118
};
#define NS_HTML_TAG_MAX 106
extern NS_HTMLPARS nsHTMLTag NS_TagToEnum(const char* aTag);
extern NS_HTMLPARS const char* NS_EnumToTag(nsHTMLTag aEnum);
#endif /* nsHTMLTags_h___ */

Просмотреть файл

@ -0,0 +1,292 @@
#! /usr/local/bin/perl
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
######################################################################
# Table of tag names; it doesn't have to be sorted because code
# below will do it. However, for the sake of ease of additions, keep
# it sorted so that its easy to tell where to add a new tag and that
# the tag hasn't already been added.
$i = 0;
$tags[$i++] = "a";
$tags[$i++] = "abbr";
$tags[$i++] = "acronym";
$tags[$i++] = "address";
$tags[$i++] = "applet";
$tags[$i++] = "area";
$tags[$i++] = "b";
$tags[$i++] = "base";
$tags[$i++] = "basefont";
$tags[$i++] = "bdo";
$tags[$i++] = "big";
$tags[$i++] = "blink";
$tags[$i++] = "blockquote";
$tags[$i++] = "body";
$tags[$i++] = "br";
$tags[$i++] = "button";
$tags[$i++] = "caption";
$tags[$i++] = "center";
$tags[$i++] = "cite";
$tags[$i++] = "code";
$tags[$i++] = "col";
$tags[$i++] = "colgroup";
$tags[$i++] = "dd";
$tags[$i++] = "del";
$tags[$i++] = "dfn";
$tags[$i++] = "dir";
$tags[$i++] = "div";
$tags[$i++] = "dl";
$tags[$i++] = "dt";
$tags[$i++] = "em";
$tags[$i++] = "embed";
$tags[$i++] = "fieldset";
$tags[$i++] = "font";
$tags[$i++] = "form";
$tags[$i++] = "frame";
$tags[$i++] = "frameset";
$tags[$i++] = "h1";
$tags[$i++] = "h2";
$tags[$i++] = "h3";
$tags[$i++] = "h4";
$tags[$i++] = "h5";
$tags[$i++] = "h6";
$tags[$i++] = "head";
$tags[$i++] = "hr";
$tags[$i++] = "html";
$tags[$i++] = "i";
$tags[$i++] = "iframe";
$tags[$i++] = "ilayer";
$tags[$i++] = "img";
$tags[$i++] = "input";
$tags[$i++] = "ins";
$tags[$i++] = "isindex";
$tags[$i++] = "kbd";
$tags[$i++] = "keygen";
$tags[$i++] = "label";
$tags[$i++] = "layer";
$tags[$i++] = "legend";
$tags[$i++] = "li";
$tags[$i++] = "link";
$tags[$i++] = "listing";
$tags[$i++] = "map";
$tags[$i++] = "menu";
$tags[$i++] = "meta";
$tags[$i++] = "multicol";
$tags[$i++] = "nobr";
$tags[$i++] = "noembed";
$tags[$i++] = "noframes";
$tags[$i++] = "nolayer";
$tags[$i++] = "noscript";
$tags[$i++] = "object";
$tags[$i++] = "ol";
$tags[$i++] = "optgroup";
$tags[$i++] = "option";
$tags[$i++] = "p";
$tags[$i++] = "param";
$tags[$i++] = "plaintext";
$tags[$i++] = "pre";
$tags[$i++] = "q";
$tags[$i++] = "s";
$tags[$i++] = "samp";
$tags[$i++] = "script";
$tags[$i++] = "select";
$tags[$i++] = "server";
$tags[$i++] = "small";
$tags[$i++] = "spacer";
$tags[$i++] = "span";
$tags[$i++] = "strike";
$tags[$i++] = "strong";
$tags[$i++] = "style";
$tags[$i++] = "sub";
$tags[$i++] = "sup";
$tags[$i++] = "table";
$tags[$i++] = "tbody";
$tags[$i++] = "td";
$tags[$i++] = "textarea";
$tags[$i++] = "tfoot";
$tags[$i++] = "th";
$tags[$i++] = "thead";
$tags[$i++] = "title";
$tags[$i++] = "tr";
$tags[$i++] = "tt";
$tags[$i++] = "u";
$tags[$i++] = "ul";
$tags[$i++] = "var";
$tags[$i++] = "wbr";
$tags[$i++] = "xmp";
######################################################################
# These are not tags; rather they are extra values to place into the
# tag enumeration after the normal tags. These do not need to be sorted
# and they do not go into the tag table, just into the tag enumeration.
$extra = 0;
$extra_tags[$extra++] = "text";
$extra_tags[$extra++] = "whitespace";
$extra_tags[$extra++] = "newline";
$extra_tags[$extra++] = "comment";
$extra_tags[$extra++] = "entity";
$extra_tags[$extra++] = "userdefined";
$extra_tags[$extra++] = "unknown";
$extra_tags[$extra++] = "secret_h1style";
$extra_tags[$extra++] = "secret_h2style";
$extra_tags[$extra++] = "secret_h3style";
$extra_tags[$extra++] = "secret_h4style";
$extra_tags[$extra++] = "secret_h5style";
$extra_tags[$extra++] = "secret_h6style";
######################################################################
# Sort the tag table before using it
@tags = sort @tags;
$copyright = "/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the \"License\"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an \"AS IS\"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Do not edit - generated by gentags.pl */
";
######################################################################
$file_base = @ARGV[0];
# Generate the header file first
open(HEADER_FILE, ">$file_base.h");
# Print out copyright and do not edit notice
print HEADER_FILE $copyright;
print HEADER_FILE "#ifndef " . $file_base . "_h___\n";
print HEADER_FILE "#define " . $file_base . "_h___\n";
print HEADER_FILE "#include \"nshtmlpars.h\"\n";
# Print out enum's for the tag symbols
print HEADER_FILE "enum nsHTMLTag {\n ";
$width = 2;
for ($j = 0; $j < $i; $j++) {
$lower = $tags[$j];
$lower =~ tr/A-Z/a-z/;
$str = "eHTMLTag_" . $lower . "=" . $j;
$str = $str . ", ";
$len = length($str);
if ($width + $len > 78) {
print HEADER_FILE "\n ";
$width = 2;
}
print HEADER_FILE $str;
$width = $width + $len;
}
print HEADER_FILE "\n\n /* The remaining enums are not for tags */\n ";
# Print out extra enum's that are not in the tag table
$width = 2;
for ($k = 0; $k < $extra; $k++) {
$lower = $extra_tags[$k];
$lower =~ tr/A-Z/a-z/;
$str = "eHTMLTag_" . $lower . "=" . ($j + $k);
if ($k < $extra - 1) {
$str = $str . ", ";
}
$len = length($str);
if ($width + $len > 78) {
print HEADER_FILE "\n ";
$width = 2;
}
print HEADER_FILE $str;
$width = $width + $len;
}
print HEADER_FILE "\n};\n#define NS_HTML_TAG_MAX " . $j . "\n\n";
print HEADER_FILE
"extern NS_HTMLPARS nsHTMLTag NS_TagToEnum(const char* aTag);\n";
print HEADER_FILE
"extern NS_HTMLPARS const char* NS_EnumToTag(nsHTMLTag aEnum);\n";
print HEADER_FILE "#endif /* " . $file_base . "_h___ */\n";
close(HEADER_FILE);
######################################################################
# Generate the source file
open(CPP_FILE, ">$file_base.cpp");
print CPP_FILE $copyright;
print CPP_FILE "#include <string.h>\n";
print CPP_FILE "#include \"$file_base.h\"\n\n";
# Print out table of tag names
print CPP_FILE "static char* tagTable[] = {\n ";
$width = 2;
for ($j = 0; $j < $i; $j++) {
$upper = $tags[$j];
$upper =~ tr/a-z/A-Z/;
$str = "\"" . $upper . "\"";
if ($j < $i - 1) {
$str = $str . ", ";
}
$len = length($str);
if ($width + $len > 78) {
print CPP_FILE "\n ";
$width = 2;
}
print CPP_FILE $str;
$width = $width + $len;
}
print CPP_FILE "\n};\n";
# Finally, dump out the search routine that takes a char* and finds it
# in the table.
print CPP_FILE "
nsHTMLTag NS_TagToEnum(const char* aTagName) {
int low = 0;
int high = NS_HTML_TAG_MAX - 1;
while (low <= high) {
int middle = (low + high) >> 1;
int result = strcmp(aTagName, tagTable[middle]);
if (result == 0)
return (nsHTMLTag) middle;
if (result < 0)
high = middle - 1;
else
low = middle + 1;
}
return eHTMLTag_userdefined;
}
const char* NS_EnumToTag(nsHTMLTag aTagID) {
if ((unsigned int)aTagID > NS_HTML_TAG_MAX) {
return 0;
}
return tagTable[(int) aTagID];
}
";
close(CPP_FILE);