Changeset 17783 in webkit


Ignore:
Timestamp:
Nov 15, 2006 10:19:37 AM (17 years ago)
Author:
lamadio
Message:

2006-11-13 Lou Amadio <lamadio@apple.com>

Reviewed by Darin Adler, Maciej Stachowiak

Cleanup: Expanded macros in generated files

  • html/HTMLElement.cpp: (WebCore::HTMLElement::isRecognizedTagName):
  • ksvg2/scripts/make_names.pl:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r17782 r17783  
     12006-11-13  Lou Amadio  <lamadio@apple.com>
     2
     3        Reviewed by Darin Adler, Maciej Stachowiak
     4
     5        Cleanup: Expanded macros in generated files
     6
     7        * html/HTMLElement.cpp:
     8        (WebCore::HTMLElement::isRecognizedTagName):
     9        * ksvg2/scripts/make_names.pl:
     10
    1112006-11-15  Anders Carlsson  <acarlsson@apple.com>
    212
  • trunk/WebCore/html/HTMLElement.cpp

    r15643 r17783  
    717717    static HashSet<AtomicStringImpl*> tagList;
    718718    if (tagList.isEmpty()) {
    719         #define ADD_TAG(name) tagList.add(name##Tag.localName().impl());
    720         DOM_HTMLNAMES_FOR_EACH_TAG(ADD_TAG)
     719        for (size_t i = 0; i < g_xhtmlTagsCount; i++)
     720            tagList.add(g_xhtmlTags[i]->localName().impl());
    721721    }
    722722    return tagList.contains(tagName.localName().impl());
  • trunk/WebCore/ksvg2/scripts/make_names.pl

    r17529 r17783  
    100100sub printMacros
    101101{
    102     my @names = @_;
     102    my ($macro, $suffix, @names) = @_;
    103103    for my $name (@names) {
    104         print "    macro($name) \\\n";
     104        print "    $macro $name","$suffix;\n";
    105105    }
    106106}
     
    205205    print "namespace $cppNamespace { namespace ${namespace}Names {\n\n";
    206206   
    207     if (scalar(@tags)) {
    208         print"#define DOM_${namespace}NAMES_FOR_EACH_TAG(macro) \\\n";
    209         printMacros(@tags);
    210         print"// end of macro\n\n";
    211     }
    212     if (scalar(@attrs)) {
    213         print "#define DOM_${namespace}NAMES_FOR_EACH_ATTR(macro) \\\n";
    214         printMacros(@attrs);
    215         print "// end of macro\n\n";
    216     }
    217    
    218207    my $lowerNamespace = lc($namespacePrefix);
    219208    print "#ifndef DOM_${namespace}NAMES_HIDE_GLOBALS\n";
     
    223212    if (scalar(@tags)) {
    224213        print "// Tags\n";
    225         print "#define DOM_NAMES_DEFINE_TAG_GLOBAL(name) extern const WebCore::QualifiedName name##Tag;\n";
    226         print "DOM_${namespace}NAMES_FOR_EACH_TAG(DOM_NAMES_DEFINE_TAG_GLOBAL)\n";
    227         print "#undef DOM_NAMES_DEFINE_TAG_GLOBAL\n\n";
     214        printMacros("extern const WebCore::QualifiedName", "Tag", @tags);
     215        print "\nextern const WebCore::QualifiedName* g_${lowerNamespace}Tags[];\n";
     216        print "extern const size_t g_${lowerNamespace}TagsCount;\n\n";
    228217    }
    229218   
    230219    if (scalar(@attrs)) {
    231220        print "// Attributes\n";
    232         print "#define DOM_NAMES_DEFINE_ATTR_GLOBAL(name) extern const WebCore::QualifiedName name##Attr;\n";
    233         print "DOM_${namespace}NAMES_FOR_EACH_ATTR(DOM_NAMES_DEFINE_ATTR_GLOBAL)\n";
    234         print "#undef DOM_NAMES_DEFINE_ATTR_GLOBAL\n\n";
     221        printMacros("extern const WebCore::QualifiedName", "Attr", @attrs);
     222        print "\nextern const WebCore::QualifiedName* g_${lowerNamespace}Attr[];\n";
     223        print "extern const size_t g_${lowerNamespace}AttrCount;\n\n";
    235224    }
    236225    print "#endif\n\n";
     
    259248print "#endif\n\n";
    260249
     250
    261251print "#include \"${namespace}Names.h\"\n\n";
    262252print "#include \"StaticConstructors.h\"\n";
     
    270260
    271261    if (scalar(@tags)) {
    272         print "#define DEFINE_TAG_GLOBAL(name) DEFINE_GLOBAL(QualifiedName, name##Tag, nullAtom, #name, ${lowerNamespace}NamespaceURI)\n";
    273         print "DOM_${namespace}NAMES_FOR_EACH_TAG(DEFINE_TAG_GLOBAL)\n\n";
     262        print "// Tags\n";
     263    for my $name (@tags) {
     264        print "DEFINE_GLOBAL(QualifiedName, ", $name, "Tag, nullAtom, \"$name\", ${lowerNamespace}NamespaceURI);\n";
     265    }
     266        print "\nconst WebCore::QualifiedName* g_${lowerNamespace}Tags[] = {\n";
     267        for my $name (@tags) {
     268            print "    &${name}Tag,\n";
     269        }
     270        print "};\n";
     271        print "const size_t g_${lowerNamespace}TagsCount = ", scalar(@tags), ";\n\n";
    274272    }
    275273
    276274    if (scalar(@attrs)) {
    277         print "#define DEFINE_ATTR_GLOBAL(name) DEFINE_GLOBAL(QualifiedName, name##Attr, nullAtom, #name, nullAtom)\n";
    278         print "DOM_${namespace}NAMES_FOR_EACH_ATTR(DEFINE_ATTR_GLOBAL)\n\n";
    279     }
    280 
    281 print "void init()
     275        print "\n// Attributes\n";
     276        for my $name (@attrs) {
     277            print "DEFINE_GLOBAL(QualifiedName, ", $name, "Attr, nullAtom, \"$name\", ${lowerNamespace}NamespaceURI);\n";
     278    }
     279        print "\nconst WebCore::QualifiedName* g_${lowerNamespace}Attr[] = {\n";
     280        for my $name (@attrs) {
     281            print "    &${name}Attr,\n";
     282        }
     283        print "};\n";
     284        print "const size_t g_${lowerNamespace}AttrCount = ", scalar(@attrs), ";\n\n";
     285    }
     286
     287print "\nvoid init()
    282288{
    283289    static bool initialized = false;
     
    326332   
    327333    print "    // " . ucfirst($type) . "\n";
    328     print "    #define DEFINE_${shortUpperType}_STRING(name) const char *name##${shortCamelType}String = #name;\n";
    329     print "    DOM_${namespace}NAMES_FOR_EACH_${shortUpperType}(DEFINE_${shortUpperType}_STRING)\n\n";
     334
     335    for my $name (@$namesRef) {
     336        print "    const char *$name","${shortCamelType}String = \"$name\";\n";
     337    }
     338       
    330339    for my $name (@$namesRef) {
    331340        if ($name =~ /_/) {
     
    335344        }
    336345    }
    337     print "\n    #define INITIALIZE_${shortUpperType}_GLOBAL(name) new ((void*)&name##${shortCamelType}) QualifiedName(nullAtom, name##${shortCamelType}String, $namespaceURI);\n";
    338     print "    DOM_${namespace}NAMES_FOR_EACH_${shortUpperType}(INITIALIZE_${shortUpperType}_GLOBAL)\n\n";
     346    print "\n";
     347
     348    for my $name (@$namesRef) {
     349        print "    new ((void*)&$name","${shortCamelType}) QualifiedName(nullAtom, $name","${shortCamelType}String, $namespaceURI);\n";
     350    }
     351
    339352}
    340353
Note: See TracChangeset for help on using the changeset viewer.