Changeset 208023 in webkit


Ignore:
Timestamp:
Oct 27, 2016 7:03:05 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

[WebIDL] Move code generators off of domSignature::type and onto domSignature::idlType
https://bugs.webkit.org/show_bug.cgi?id=164089

Patch by Sam Weinig <sam@webkit.org> on 2016-10-27
Reviewed by Alex Christensen.

Source/WebCore:

Make more IDLParser structures contain domTypes for type descriptions, rather than strings:

  • domInterface gains type and parentType.
  • domConstant gains type.
  • domEnum gains type.
  • domDictionary gains type and parentType.

With these structs now containing domTypes, we can update the CodeGenerators to operate on
domTypes exclusively, rather than types as strings. This allows us to consistently have access
to information such as subtypes and nullability.

  • bindings/scripts/CodeGenerator.pm:

Update helpers to operate of domTypes. The one exception is SkipIncludeHeader, which
still operates on a type name, since it is called late in code generation on the textual
form of type names in the include list.

  • bindings/scripts/CodeGeneratorJS.pm:

Update to use domTypes.

  • bindings/scripts/IDLParser.pm:
  • Add domType accessors to domInterface, domConstant, domEnum, and domDictionary and populate them.
  • Remove type accessors from domSignature (domType is accessible from idlType).
  • Remove special cases for sequence and FrozenArray, now that they are always accessed as domTypes.
  • html/HTMLEmbedElement.idl:
  • html/HTMLFrameElement.idl:
  • html/HTMLFrameOwnerElement.cpp:

(WebCore::HTMLFrameOwnerElement::getSVGDocument):

  • html/HTMLFrameOwnerElement.h:
  • html/HTMLIFrameElement.idl:
  • html/HTMLObjectElement.idl:

Fix interfaces declaring getSVGDocument() to correctly have it return
a Document, rather than an SVGDocument, which does exist anymore. To
make the bindings happy, also change the signature of HTMLFrameOwnerElement::getSVGDocument
to return a Document.

  • bindings/scripts/test/JS/JSTestEventTarget.cpp:
  • bindings/scripts/test/JS/JSTestInterface.cpp:
  • bindings/scripts/test/JS/JSTestObj.cpp:
  • bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
  • bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp:
  • bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
  • bindings/scripts/test/JS/JSTestTypedefs.cpp:

Update test results to remove some redundant headers (Already included JSFoo.h, so no need for Foo.h).

Tools:

  • DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm:
  • WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:

Update for the removal of domSignature::type, and new signatures of helper predicates.

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r208022 r208023  
     12016-10-27  Sam Weinig  <sam@webkit.org>
     2
     3        [WebIDL] Move code generators off of domSignature::type and onto domSignature::idlType
     4        https://bugs.webkit.org/show_bug.cgi?id=164089
     5
     6        Reviewed by Alex Christensen.
     7
     8        Make more IDLParser structures contain domTypes for type descriptions, rather than strings:
     9        - domInterface gains type and parentType.
     10        - domConstant gains type.
     11        - domEnum gains type.
     12        - domDictionary gains type and parentType.
     13
     14        With these structs now containing domTypes, we can update the CodeGenerators to operate on
     15        domTypes exclusively, rather than types as strings. This allows us to consistently have access
     16        to information such as subtypes and nullability.
     17
     18        * bindings/scripts/CodeGenerator.pm:
     19        Update helpers to operate of domTypes. The one exception is SkipIncludeHeader, which
     20        still operates on a type name, since it is called late in code generation on the textual
     21        form of type names in the include list.
     22
     23        * bindings/scripts/CodeGeneratorJS.pm:
     24        Update to use domTypes.
     25
     26        * bindings/scripts/IDLParser.pm:
     27        - Add domType accessors to domInterface, domConstant, domEnum, and domDictionary
     28          and populate them.
     29        - Remove type accessors from domSignature (domType is accessible from idlType).
     30        - Remove special cases for sequence and FrozenArray, now that they are always
     31          accessed as domTypes.
     32
     33        * html/HTMLEmbedElement.idl:
     34        * html/HTMLFrameElement.idl:
     35        * html/HTMLFrameOwnerElement.cpp:
     36        (WebCore::HTMLFrameOwnerElement::getSVGDocument):
     37        * html/HTMLFrameOwnerElement.h:
     38        * html/HTMLIFrameElement.idl:
     39        * html/HTMLObjectElement.idl:
     40        Fix interfaces declaring getSVGDocument() to correctly have it return
     41        a Document, rather than an SVGDocument, which does exist anymore. To
     42        make the bindings happy, also change the signature of HTMLFrameOwnerElement::getSVGDocument
     43        to return a Document.
     44
     45        * bindings/scripts/test/JS/JSTestEventTarget.cpp:
     46        * bindings/scripts/test/JS/JSTestInterface.cpp:
     47        * bindings/scripts/test/JS/JSTestObj.cpp:
     48        * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
     49        * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp:
     50        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
     51        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
     52        Update test results to remove some redundant headers (Already included JSFoo.h, so no need for Foo.h).
     53
    1542016-10-27  Myles C. Maxfield  <mmaxfield@apple.com>
    255
  • trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm

    r207937 r208023  
    274274        my $currentInterface = shift;
    275275
    276         for (@{$currentInterface->parents}) {
    277             my $interfaceName = $_;
     276        if  ($currentInterface->parentType) {
     277            my $interfaceName = $currentInterface->parentType->name;
    278278            my $parentInterface = $object->ParseInterface($outerInterface, $interfaceName);
    279279
     
    327327}
    328328
    329 sub GetAttributeFromInterface()
    330 {
    331     my $object = shift;
    332     my $outerInterface = shift;
    333     my $interfaceName = shift;
    334     my $attributeName = shift;
     329sub GetAttributeFromInterface
     330{
     331    my ($object, $outerInterface, $interfaceName, $attributeName) = @_;
    335332
    336333    my $interface = $object->ParseInterface($outerInterface, $interfaceName);
     
    378375sub SkipIncludeHeader
    379376{
    380     my $object = shift;
    381     my $type = shift;
     377    my ($object, $typeName) = @_;
    382378
    383379    # FIXME: This is a lot like !IsRefPtrType. Maybe they could share code?
    384380
    385     return 1 if $object->IsPrimitiveType($type);
    386     return 1 if $object->IsTypedArrayType($type);
    387     return 1 if $type eq "Array";
    388     return 1 if $type eq "BufferSource";
    389     return 1 if $type eq "DOMString" or $type eq "USVString";
    390     return 1 if $type eq "DOMTimeStamp";
    391     return 1 if $type eq "SVGNumber";
    392     return 1 if $type eq "any";
     381    return 1 if $primitiveTypeHash{$typeName};
     382    return 1 if $integerTypeHash{$typeName};
     383    return 1 if $floatingPointTypeHash{$typeName};
     384    return 1 if $typedArrayTypes{$typeName};
     385    return 1 if $typeName eq "DOMString";
     386    return 1 if $typeName eq "USVString";
     387    return 1 if $typeName eq "BufferSource";
     388    return 1 if $typeName eq "SVGNumber";
     389    return 1 if $typeName eq "any";
    393390
    394391    return 0;
     
    399396    my ($object, $type) = @_;
    400397
    401     return 1 if $integerTypeHash{$type};
    402     return 1 if $floatingPointTypeHash{$type};
     398    assert("Not a type") if ref($type) ne "domType";
     399
     400    return 1 if $integerTypeHash{$type->name};
     401    return 1 if $floatingPointTypeHash{$type->name};
    403402    return 0;
    404403}
     
    408407    my ($object, $type) = @_;
    409408   
    410     return 1 if $type eq "DOMString" or $type eq "USVString";
     409    assert("Not a type") if ref($type) ne "domType";
     410
     411    return 1 if $object->IsStringType($type);
    411412    return 1 if $object->IsEnumType($type);
    412413    return 0;
     
    417418    my ($object, $type) = @_;
    418419
    419     return 1 if $integerTypeHash{$type};
     420    assert("Not a type") if ref($type) ne "domType";
     421
     422    return 1 if $integerTypeHash{$type->name};
    420423    return 0;
    421424}
     
    425428    my ($object, $type) = @_;
    426429
    427     return 1 if $floatingPointTypeHash{$type};
     430    assert("Not a type") if ref($type) ne "domType";
     431
     432    return 1 if $floatingPointTypeHash{$type->name};
    428433    return 0;
    429434}
     
    433438    my ($object, $type) = @_;
    434439
    435     return 1 if $primitiveTypeHash{$type};
     440    assert("Not a type") if ref($type) ne "domType";
     441
     442    return 1 if $primitiveTypeHash{$type->name};
    436443    return 1 if $object->IsNumericType($type);
    437444    return 0;
     
    443450    my ($object, $type) = @_;
    444451
    445     return 1 if $type eq "DOMString";
    446     return 1 if $type eq "USVString";
     452    assert("Not a type") if ref($type) ne "domType";
     453
     454    return 1 if $type->name eq "DOMString";
     455    return 1 if $type->name eq "USVString";
    447456    return 0;
    448457}
     
    452461    my ($object, $type) = @_;
    453462
    454     return defined($object->GetEnumByName($type));
    455 }
    456 
    457 sub GetEnumByName
    458 {
    459     my ($object, $name) = @_;
    460    
     463    assert("Not a type") if ref($type) ne "domType";
     464
     465    return defined($object->GetEnumByType($type));
     466}
     467
     468sub GetEnumByType
     469{
     470    my ($object, $type) = @_;
     471
     472    assert("Not a type") if ref($type) ne "domType";
     473
     474    my $name = $type->name;
     475
    461476    die "GetEnumByName() was called with an undefined enumeration name" unless defined($name);
    462477
     
    495510    my ($object, $type) = @_;
    496511
    497     return $object->IsEnumType($type) && defined($cachedExternalEnumerations->{$type});
    498 }
    499 
    500 sub ValidEnumValues
    501 {
    502     my ($object, $type) = @_;
    503 
    504     my $enumeration = $object->GetEnumByName($type);
    505     die "ValidEnumValues() was with a type that is not an enumeration: " . $type unless defined($enumeration);
    506 
    507     return $enumeration->values;
     512    assert("Not a type") if ref($type) ne "domType";
     513
     514    return $object->IsEnumType($type) && defined($cachedExternalEnumerations->{$type->name});
    508515}
    509516
     
    512519    my ($object, $type) = @_;
    513520
    514     return 1 if exists $enumTypeImplementationNameOverrides{$type};
     521    assert("Not a type") if ref($type) ne "domType";
     522
     523    return 1 if exists $enumTypeImplementationNameOverrides{$type->name};
    515524    return 0;
    516525}
     
    520529    my ($object, $type) = @_;
    521530
    522     return $enumTypeImplementationNameOverrides{$type};
    523 }
    524 
    525 sub GetDictionaryByName
    526 {
    527     my ($object, $name) = @_;
    528     die "GetDictionaryByName() was called with an undefined dictionary name" unless defined($name);
     531    assert("Not a type") if ref($type) ne "domType";
     532
     533    return $enumTypeImplementationNameOverrides{$type->name};
     534}
     535
     536sub GetDictionaryByType
     537{
     538    my ($object, $type) = @_;
     539
     540    assert("Not a type") if ref($type) ne "domType";
     541
     542    my $name = $type->name;
     543
     544    die "GetDictionaryByType() was called with an undefined dictionary name" unless defined($name);
    529545
    530546    for my $dictionary (@{$useDocument->dictionaries}) {
     
    561577    my ($object, $type) = @_;
    562578
    563     return $type =~ /^[A-Z]/ && defined($object->GetDictionaryByName($type));
     579    assert("Not a type") if ref($type) ne "domType";
     580
     581    return $type->name =~ /^[A-Z]/ && defined($object->GetDictionaryByType($type));
    564582}
    565583
     
    569587    my ($object, $type) = @_;
    570588
    571     return $object->IsDictionaryType($type) && defined($cachedExternalDictionaries->{$type});
     589    assert("Not a type") if ref($type) ne "domType";
     590
     591    return $object->IsDictionaryType($type) && defined($cachedExternalDictionaries->{$type->name});
    572592}
    573593
     
    576596    my ($object, $type) = @_;
    577597
    578     return 1 if exists $dictionaryTypeImplementationNameOverrides{$type};
     598    assert("Not a type") if ref($type) ne "domType";
     599
     600    return 1 if exists $dictionaryTypeImplementationNameOverrides{$type->name};
    579601    return 0;
    580602}
     
    584606    my ($object, $type) = @_;
    585607
    586     return $dictionaryTypeImplementationNameOverrides{$type};
     608    assert("Not a type") if ref($type) ne "domType";
     609
     610    return $dictionaryTypeImplementationNameOverrides{$type->name};
    587611}
    588612
     
    591615    my ($object, $type) = @_;
    592616
    593     return 1 if $nonPointerTypeHash{$type};
     617    assert("Not a type") if ref($type) ne "domType";
     618
     619    return 1 if $nonPointerTypeHash{$type->name};
    594620    return 1 if $object->IsPrimitiveType($type);
    595621    return 0;
    596622}
    597623
    598 sub IsSVGTypeNeedingTearOff
    599 {
    600     my $object = shift;
    601     my $type = shift;
    602 
    603     return 1 if exists $svgTypeNeedingTearOff{$type};
    604     return 0;
    605 }
    606 
    607 sub IsSVGTypeWithWritablePropertiesNeedingTearOff
    608 {
    609     my $object = shift;
    610     my $type = shift;
    611 
    612     return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type};
     624sub IsSVGTypeNeedingTearOffForType
     625{
     626    my ($object, $type) = @_;
     627
     628    assert("Not a type") if ref($type) ne "domType";
     629
     630    return 1 if exists $svgTypeNeedingTearOff{$type->name};
     631    return 0;
     632}
     633
     634sub IsSVGTypeWithWritablePropertiesNeedingTearOffForType
     635{
     636    my ($object, $type) = @_;
     637
     638    assert("Not a type") if ref($type) ne "domType";
     639
     640    return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type->name};
    613641    return 0;
    614642}
     
    616644sub IsTypedArrayType
    617645{
    618     my $object = shift;
    619     my $type = shift;
    620 
    621     return 1 if $typedArrayTypes{$type};
     646    my ($object, $type) = @_;
     647
     648    assert("Not a type") if ref($type) ne "domType";
     649
     650    return 1 if $typedArrayTypes{$type->name};
    622651    return 0;
    623652}
     
    625654sub IsRefPtrType
    626655{
    627     my $object = shift;
    628     my $type = shift;
     656    my ($object, $type) = @_;
     657
     658    assert("Not a type") if ref($type) ne "domType";
    629659
    630660    return 0 if $object->IsPrimitiveType($type);
     
    632662    return 0 if $object->IsEnumType($type);
    633663    return 0 if $object->IsSequenceOrFrozenArrayType($type);
    634     return 0 if $type eq "DOMString" or $type eq "USVString";
    635     return 0 if $type eq "any";
     664    return 0 if $object->IsStringType($type);
     665    return 0 if $type->name eq "any";
    636666
    637667    return 1;
    638668}
    639669
    640 sub GetSVGTypeNeedingTearOff
    641 {
    642     my $object = shift;
    643     my $type = shift;
    644 
    645     return $svgTypeNeedingTearOff{$type} if exists $svgTypeNeedingTearOff{$type};
     670sub GetSVGTypeNeedingTearOffForType
     671{
     672    my ($object, $type) = @_;
     673
     674    assert("Not a type") if ref($type) ne "domType";
     675
     676    return $svgTypeNeedingTearOff{$type->name} if exists $svgTypeNeedingTearOff{$type->name};
    646677    return undef;
    647678}
    648679
    649 sub GetSVGWrappedTypeNeedingTearOff
    650 {
    651     my $object = shift;
    652     my $type = shift;
    653 
    654     my $svgTypeNeedingTearOff = $object->GetSVGTypeNeedingTearOff($type);
     680sub GetSVGWrappedTypeNeedingTearOffForType
     681{
     682    my ($object, $type) = @_;
     683
     684    assert("Not a type") if ref($type) ne "domType";
     685
     686    my $svgTypeNeedingTearOff = $object->GetSVGTypeNeedingTearOffForType($type);
    655687    return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff;
    656688
     
    669701}
    670702
     703sub IsSVGAnimatedTypeName
     704{
     705    my ($object, $typeName) = @_;
     706
     707    return $typeName =~ /^SVGAnimated/;
     708}
     709
    671710sub IsSVGAnimatedType
    672711{
    673     my $object = shift;
    674     my $type = shift;
    675 
    676     return $type =~ /^SVGAnimated/;
     712    my ($object, $type) = @_;
     713
     714    assert("Not a type") if ref($type) ne "domType";
     715
     716    return $object->IsSVGAnimatedTypeName($type->name);
     717}
     718
     719sub IsConstructorType
     720{
     721    my ($object, $type) = @_;
     722
     723    assert("Not a type") if ref($type) ne "domType";
     724
     725    return $type->name =~ /Constructor$/;
    677726}
    678727
    679728sub IsSequenceType
    680729{
    681     my $object = shift;
    682     my $type = shift;
    683 
    684     return $type =~ /^sequence</;
     730    my ($object, $type) = @_;
     731
     732    assert("Not a type") if ref($type) ne "domType";
     733
     734    return $type->name eq "sequence";
    685735}
    686736
    687737sub GetSequenceInnerType
    688738{
    689     my $object = shift;
    690     my $type = shift;
    691 
    692     return $1 if $type =~ /^sequence<([\w\d_\s]+)>.*/;
    693     return "";
     739    my ($object, $type) = @_;
     740
     741    assert("Not a type") if ref($type) ne "domType";
     742
     743    return @{$type->subtypes}[0];
    694744}
    695745
    696746sub IsFrozenArrayType
    697747{
    698     my $object = shift;
    699     my $type = shift;
    700 
    701     return $type =~ /^FrozenArray</;
     748    my ($object, $type) = @_;
     749
     750    assert("Not a type") if ref($type) ne "domType";
     751
     752    # FIXME: Update parser to make this just 'FrozenArray'
     753    return $type->name eq "FrozenArray";
    702754}
    703755
    704756sub GetFrozenArrayInnerType
    705757{
    706     my $object = shift;
    707     my $type = shift;
    708 
    709     return $1 if $type =~ /^FrozenArray<([\w\d_\s]+)>.*/;
    710     return "";
     758    my ($object, $type) = @_;
     759
     760    assert("Not a type") if ref($type) ne "domType";
     761
     762    return @{$type->subtypes}[0];
    711763}
    712764
    713765sub IsSequenceOrFrozenArrayType
    714766{
    715     my $object = shift;
    716     my $type = shift;
     767    my ($object, $type) = @_;
     768
     769    assert("Not a type") if ref($type) ne "domType";
    717770
    718771    return $object->IsSequenceType($type) || $object->IsFrozenArrayType($type);
     
    721774sub GetSequenceOrFrozenArrayInnerType
    722775{
    723     my $object = shift;
    724     my $type = shift;
    725 
    726     return $object->GetSequenceInnerType($type) if $object->IsSequenceType($type);
    727     return $object->GetFrozenArrayInnerType($type) if $object->IsFrozenArrayType($type);
    728     return "";
     776    my ($object, $type) = @_;
     777
     778    assert("Not a type") if ref($type) ne "domType";
     779
     780    return @{$type->subtypes}[0];
    729781}
    730782
     
    735787{
    736788    my ($object, $param) = @_;
     789
    737790    my $ret = ucfirst($param);
    738791    $ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/;
     
    747800{
    748801    my ($object, $param) = @_;
     802
    749803    my $ret = lcfirst($param);
    750804    $ret =~ s/dOM/dom/ if $ret =~ /^dOM/;
     
    765819}
    766820
    767 sub slurp {
     821sub slurp
     822{
    768823    my $file = shift;
    769824
     
    778833{
    779834    my $string = shift;
     835
    780836    $string =~ s/^\s+|\s+$//g;
    781837    return $string;
     
    786842{
    787843    my ($object, $interfaceName, $attributeName) = @_;
     844
    788845    return "SVGNames" if $interfaceName =~ /^SVG/ && !$svgAttributesInHTMLHash{$attributeName};
    789846    return "HTMLNames";
     
    821878        $attributeName = $attribute->signature->extendedAttributes->{"ImplementedAs"};
    822879    }
    823     my $attributeType = $attribute->signature->type;
     880    my $attributeType = $attribute->signature->idlType;
    824881
    825882    # SVG animated types need to use a special attribute name.
     
    855912    }
    856913
    857     my $attributeType = $attribute->signature->type;
     914    my $attributeType = $attribute->signature->idlType;
    858915
    859916    my $functionName;
    860917    if ($attribute->signature->extendedAttributes->{"URL"}) {
    861918        $functionName = "getURLAttribute";
    862     } elsif ($attributeType eq "boolean") {
     919    } elsif ($attributeType->name eq "boolean") {
    863920        $functionName = "hasAttributeWithoutSynchronization";
    864     } elsif ($attributeType eq "long") {
     921    } elsif ($attributeType->name eq "long") {
    865922        $functionName = "getIntegralAttribute";
    866     } elsif ($attributeType eq "unsigned long") {
     923    } elsif ($attributeType->name eq "unsigned long") {
    867924        $functionName = "getUnsignedIntegralAttribute";
    868925    } else {
     
    893950    }
    894951
    895     my $attributeType = $attribute->signature->type;
     952    my $attributeType = $attribute->signature->idlType;
    896953
    897954    my $functionName;
    898     if ($attributeType eq "boolean") {
     955    if ($attributeType->name eq "boolean") {
    899956        $functionName = "setBooleanAttribute";
    900     } elsif ($attributeType eq "long") {
     957    } elsif ($attributeType->name eq "long") {
    901958        $functionName = "setIntegralAttribute";
    902     } elsif ($attributeType eq "unsigned long") {
     959    } elsif ($attributeType->name eq "unsigned long") {
    903960        $functionName = "setUnsignedIntegralAttribute";
    904961    } elsif ($generator->IsSVGAnimatedType($attributeType)) {
     
    913970sub IsWrapperType
    914971{
    915     my $object = shift;
    916     my $type = shift;
     972    my ($object, $type) = @_;
     973
     974    assert("Not a type") if ref($type) ne "domType";
    917975
    918976    return 0 if !$object->IsRefPtrType($type);
    919977    return 0 if $object->IsTypedArrayType($type);
    920     return 0 if $type eq "BufferSource";
    921     return 0 if $type eq "UNION";
    922     return 0 if $webCoreTypeHash{$type};
     978    return 0 if $type->name eq "BufferSource";
     979    return 0 if $type->name eq "UNION";
     980    return 0 if $webCoreTypeHash{$type->name};
    923981
    924982    return 1;
    925983}
    926984
    927 sub getInterfaceExtendedAttributesFromName
     985sub GetInterfaceExtendedAttributesFromName
    928986{
    929987    # FIXME: It's bad to have a function like this that opens another IDL file to answer a question.
    930988    # Overusing this kind of function can make things really slow. Lets avoid these if we can.
    931989
    932     my $object = shift;
    933     my $interfaceName = shift;
     990    my ($object, $interfaceName) = @_;
    934991
    935992    my $idlFile = $object->IDLFileForInterface($interfaceName) or assert("Could NOT find IDL file for interface \"$interfaceName\"!\n");
     
    9601017sub ComputeIsCallbackInterface
    9611018{
    962   my $object = shift;
    963   my $type = shift;
    964 
    965   return 0 unless $object->IsWrapperType($type);
    966 
    967   my $idlFile = $object->IDLFileForInterface($type) or assert("Could NOT find IDL file for interface \"$type\"!\n");
    968 
    969   open FILE, "<", $idlFile or die;
    970   my @lines = <FILE>;
    971   close FILE;
    972 
    973   my $fileContents = join('', @lines);
    974   return ($fileContents =~ /callback\s+interface\s+(\w+)/gs);
     1019    my ($object, $type) = @_;
     1020
     1021    assert("Not a type") if ref($type) ne "domType";
     1022
     1023    return 0 unless $object->IsWrapperType($type);
     1024
     1025    my $typeName = $type->name;
     1026    my $idlFile = $object->IDLFileForInterface($typeName) or assert("Could NOT find IDL file for interface \"$typeName\"!\n");
     1027
     1028    open FILE, "<", $idlFile or die;
     1029    my @lines = <FILE>;
     1030    close FILE;
     1031
     1032    my $fileContents = join('', @lines);
     1033    return ($fileContents =~ /callback\s+interface\s+(\w+)/gs);
    9751034}
    9761035
     
    9851044    my ($object, $type) = @_;
    9861045
    987     return $isCallbackInterface{$type} if exists $isCallbackInterface{$type};
    988     my $result = ComputeIsCallbackInterface($object, $type);
    989     $isCallbackInterface{$type} = $result;
     1046    assert("Not a type") if ref($type) ne "domType";
     1047
     1048    return $isCallbackInterface{$type->name} if exists $isCallbackInterface{$type->name};
     1049    my $result = $object->ComputeIsCallbackInterface($type);
     1050    $isCallbackInterface{$type->name} = $result;
    9901051    return $result;
    9911052}
     
    9961057sub ComputeIsFunctionOnlyCallbackInterface
    9971058{
    998   my $object = shift;
    999   my $type = shift;
    1000 
    1001   return 0 unless $object->IsCallbackInterface($type);
    1002 
    1003   my $idlFile = $object->IDLFileForInterface($type) or assert("Could NOT find IDL file for interface \"$type\"!\n");
    1004 
    1005   open FILE, "<", $idlFile or die;
    1006   my @lines = <FILE>;
    1007   close FILE;
    1008 
    1009   my $fileContents = join('', @lines);
    1010   if ($fileContents =~ /\[(.*)\]\s+callback\s+interface\s+(\w+)/gs) {
    1011       my @parts = split(',', $1);
    1012       foreach my $part (@parts) {
    1013           my @keyValue = split('=', $part);
    1014           my $key = trim($keyValue[0]);
    1015           next unless length($key);
    1016           my $value = "VALUE_IS_MISSING";
    1017           $value = trim($keyValue[1]) if @keyValue > 1;
    1018 
    1019           return 1 if ($key eq "Callback" && $value eq "FunctionOnly");
    1020       }
    1021   }
    1022 
    1023   return 0;
     1059    my ($object, $type) = @_;
     1060
     1061    assert("Not a type") if ref($type) ne "domType";
     1062
     1063    return 0 unless $object->IsCallbackInterface($type);
     1064
     1065    my $typeName = $type->name;
     1066    my $idlFile = $object->IDLFileForInterface($typeName) or assert("Could NOT find IDL file for interface \"$typeName\"!\n");
     1067
     1068    open FILE, "<", $idlFile or die;
     1069    my @lines = <FILE>;
     1070    close FILE;
     1071
     1072    my $fileContents = join('', @lines);
     1073    if ($fileContents =~ /\[(.*)\]\s+callback\s+interface\s+(\w+)/gs) {
     1074        my @parts = split(',', $1);
     1075        foreach my $part (@parts) {
     1076            my @keyValue = split('=', $part);
     1077            my $key = trim($keyValue[0]);
     1078            next unless length($key);
     1079            my $value = "VALUE_IS_MISSING";
     1080            $value = trim($keyValue[1]) if @keyValue > 1;
     1081
     1082            return 1 if ($key eq "Callback" && $value eq "FunctionOnly");
     1083        }
     1084    }
     1085
     1086    return 0;
    10241087}
    10251088
     
    10341097    my ($object, $type) = @_;
    10351098
    1036     return $isFunctionOnlyCallbackInterface{$type} if exists $isFunctionOnlyCallbackInterface{$type};
    1037     my $result = ComputeIsFunctionOnlyCallbackInterface($object, $type);
    1038     $isFunctionOnlyCallbackInterface{$type} = $result;
     1099    assert("Not a type") if ref($type) ne "domType";
     1100
     1101    return $isFunctionOnlyCallbackInterface{$type->name} if exists $isFunctionOnlyCallbackInterface{$type->name};
     1102    my $result = $object->ComputeIsFunctionOnlyCallbackInterface($type);
     1103    $isFunctionOnlyCallbackInterface{$type->name} = $result;
    10391104    return $result;
    10401105}
     
    10421107sub GenerateConditionalString
    10431108{
    1044     my $generator = shift;
    1045     my $node = shift;
     1109    my ($generator, $node) = @_;
    10461110
    10471111    my $conditional = $node->extendedAttributes->{"Conditional"};
     
    10551119sub GenerateConditionalStringFromAttributeValue
    10561120{
    1057     my $generator = shift;
    1058     my $conditional = shift;
     1121    my ($generator, $conditional) = @_;
    10591122
    10601123    my %disjunction;
     
    11151178sub GetVisibleInterfaceName
    11161179{
    1117     my $object = shift;
    1118     my $interface = shift;
     1180    my ($object, $interface) = @_;
     1181
    11191182    my $interfaceName = $interface->extendedAttributes->{"InterfaceName"};
    11201183    return $interfaceName ? $interfaceName : $interface->name;
     
    11231186sub InheritsInterface
    11241187{
    1125     my $object = shift;
    1126     my $interface = shift;
    1127     my $interfaceName = shift;
     1188    my ($object, $interface, $interfaceName) = @_;
     1189
     1190    return 1 if $interfaceName eq $interface->name;
     1191
    11281192    my $found = 0;
    1129 
    1130     return 1 if $interfaceName eq $interface->name;
    11311193    $object->ForAllParents($interface, sub {
    11321194        my $currentInterface = shift;
     
    11421204sub InheritsExtendedAttribute
    11431205{
    1144     my $object = shift;
    1145     my $interface = shift;
    1146     my $extendedAttribute = shift;
     1206    my ($object, $interface, $extendedAttribute) = @_;
     1207
     1208    return 1 if $interface->extendedAttributes->{$extendedAttribute};
     1209
    11471210    my $found = 0;
    1148 
    1149     return 1 if $interface->extendedAttributes->{$extendedAttribute};
    11501211    $object->ForAllParents($interface, sub {
    11511212        my $currentInterface = shift;
     
    11611222sub ShouldPassWrapperByReference
    11621223{
    1163     my $object = shift;
    1164     my $parameter = shift;
    1165     my $interface = shift;
     1224    my ($object, $parameter, $interface) = @_;
    11661225
    11671226    return 0 if $parameter->isVariadic;
    11681227    return 0 if $parameter->isNullable;
    1169     return 0 if !$object->IsWrapperType($parameter->type) && !$object->IsTypedArrayType($parameter->type);
    1170     return 0 if $object->IsSVGTypeNeedingTearOff($parameter->type);
     1228    return 0 if !$object->IsWrapperType($parameter->idlType) && !$object->IsTypedArrayType($parameter->idlType);
     1229    return 0 if $object->IsSVGTypeNeedingTearOffForType($parameter->idlType);
    11711230
    11721231    return 1;
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r207937 r208023  
    137137    my ($object, $enumeration) = @_;
    138138
    139     my $className = GetEnumerationClassName($enumeration->name);
     139    my $className = GetEnumerationClassName($enumeration->type);
    140140    $object->GenerateEnumerationHeader($enumeration, $className);
    141141    $object->GenerateEnumerationImplementation($enumeration, $className);
     
    146146    my ($object, $dictionary, $enumerations) = @_;
    147147
    148     my $className = GetDictionaryClassName($dictionary->name);
     148    my $className = GetDictionaryClassName($dictionary->type);
    149149    $object->GenerateDictionaryHeader($dictionary, $className, $enumerations);
    150150    $object->GenerateDictionaryImplementation($dictionary, $className, $enumerations);
     
    180180        $stringifier->signature->extendedAttributes($extendedAttributeList);
    181181        $stringifier->signature->name("toString");
    182         die "stringifier can only be used on attributes of String types" unless $codeGenerator->IsStringType($attribute->signature->type);
     182        die "stringifier can only be used on attributes of String types" unless $codeGenerator->IsStringType($attribute->signature->idlType);
    183183       
    184184        # FIXME: This should use IDLParser's cloneType.
    185185        my $type = domType->new();
    186         $type->name($attribute->signature->type);
     186        $type->name($attribute->signature->idlType->name);
    187187
    188188        $stringifier->signature->idlType($type);
    189         $stringifier->signature->type($type->name);
    190189
    191190        push(@{$interface->functions}, $stringifier);
     
    211210    return $interface->extendedAttributes->{JSLegacyParent} if $interface->extendedAttributes->{JSLegacyParent};
    212211    return "JSDOMObject" unless NeedsImplementationClass($interface);
    213     return "JSDOMWrapper<" . GetImplClassName($interface->name) . ">" unless $interface->parent;
     212    return "JSDOMWrapper<" . GetImplClassName($interface) . ">" unless $interface->parent;
    214213    return "JS" . $interface->parent;
    215214}
     
    227226
    228227    return $callbackInterface->extendedAttributes->{IsWeakCallback} ? "JSCallbackDataWeak" : "JSCallbackDataStrong";
    229 }
    230 
    231 sub AddIncludesForTypeInImpl
    232 {
    233     my $type = shift;
    234     my $isCallback = @_ ? shift : 0;
    235    
    236     AddIncludesForType($type, $isCallback, \%implIncludes);
    237 }
    238 
    239 sub AddIncludesForTypeInHeader
    240 {
    241     my $type = shift;
    242     my $isCallback = @_ ? shift : 0;
    243    
    244     AddIncludesForType($type, $isCallback, \%headerIncludes);
    245228}
    246229
     
    253236}
    254237
    255 sub AddIncludesForType
    256 {
    257     my $type = shift;
    258     my $isCallback = shift;
    259     my $includesRef = shift;
    260 
    261     return if $codeGenerator->SkipIncludeHeader($type);
     238sub AddIncludesForImplementationTypeInImpl
     239{
     240    my $implementationType = shift;
    262241   
    263     # When we're finished with the one-file-per-class reorganization, we won't need these special cases.
    264     if ($isCallback && $codeGenerator->IsWrapperType($type)) {
    265         $includesRef->{"JS${type}.h"} = 1;
    266     } elsif ($codeGenerator->IsSequenceOrFrozenArrayType($type)) {
    267         my $innerType = $codeGenerator->GetSequenceOrFrozenArrayInnerType($type);
    268         if ($codeGenerator->IsRefPtrType($innerType)) {
    269             $includesRef->{"JS${innerType}.h"} = 1;
    270             $includesRef->{"${innerType}.h"} = 1;
    271         }
    272         $includesRef->{"<runtime/JSArray.h>"} = 1;
    273     } else {
    274         # default, include the same named file
    275         $includesRef->{"${type}.h"} = 1;
    276     }
     242    AddIncludesForImplementationType($implementationType, \%implIncludes);
     243}
     244
     245sub AddIncludesForImplementationTypeInHeader
     246{
     247    my $implementationType = shift;
     248   
     249    AddIncludesForImplementationType($implementationType, \%headerIncludes);
     250}
     251
     252sub AddIncludesForImplementationType
     253{
     254    my ($implementationType, $includesRef) = @_;
     255
     256    return if $codeGenerator->SkipIncludeHeader($implementationType);
     257
     258    $includesRef->{"${implementationType}.h"} = 1;
    277259}
    278260
     
    293275    }
    294276
    295     if ($codeGenerator->IsSequenceOrFrozenArrayType($idlType->name)) {
     277    if ($codeGenerator->IsSequenceOrFrozenArrayType($idlType)) {
     278        AddToImplIncludes("<runtime/JSArray.h>", $conditional);
    296279        AddToImplIncludesForIDLType(@{$idlType->subtypes}[0], $conditional);
    297280        return;
    298281    }
    299282
    300     if ($codeGenerator->IsExternalDictionaryType($idlType->name) || $codeGenerator->IsExternalEnumType($idlType->name)) {
    301         AddToImplIncludes("JS" . $idlType->name . ".h", $conditional);
    302         return;
    303     }
    304 
    305     if ($codeGenerator->IsWrapperType($idlType->name)) {
     283    if ($codeGenerator->IsWrapperType($idlType) || $codeGenerator->IsExternalDictionaryType($idlType) || $codeGenerator->IsExternalEnumType($idlType)) {
    306284        AddToImplIncludes("JS" . $idlType->name . ".h", $conditional);
    307285        return;
     
    332310sub AddClassForwardIfNeeded
    333311{
    334     my $interfaceName = shift;
     312    my $type = shift;
    335313
    336314    # SVGAnimatedLength/Number/etc. are not classes so they can't be forward declared as classes.
    337     return if $codeGenerator->IsSVGAnimatedType($interfaceName);
    338 
    339     return if $codeGenerator->IsTypedArrayType($interfaceName);
    340     return if $interfaceName eq "BufferSource";
    341 
    342     push(@headerContent, "class $interfaceName;\n\n");
     315    return if $codeGenerator->IsSVGAnimatedType($type);
     316    return if $codeGenerator->IsTypedArrayType($type);
     317    return if $type->name eq "BufferSource";
     318
     319    push(@headerContent, "class " . $type->name . ";\n\n");
    343320}
    344321
     
    400377        # If the item function returns a string then we let the TreatReturnedNullStringAs handle the cases
    401378        # where the index is out of range.
    402         if ($indexedGetterFunction->signature->type eq "DOMString") {
     379       
     380        # FIXME: Should this work for all string types?
     381        if ($indexedGetterFunction->signature->idlType->name eq "DOMString") {
    403382            push(@getOwnPropertySlotImpl, "    if (optionalIndex) {\n");
    404383        } else {
     
    557536    return $codeGenerator->WK_lcfirst($className) . "Constructor" . $codeGenerator->WK_ucfirst($attribute->signature->name) if $attribute->isStatic;
    558537    return GetJSBuiltinFunctionName($className, $attribute) if IsJSBuiltin($interface, $attribute);
    559     return "js" . $interface->name . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     538    return "js" . $interface->name . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($codeGenerator->IsConstructorType($attribute->signature->idlType) ? "Constructor" : "");
    560539}
    561540
     
    566545    return "set" . $codeGenerator->WK_ucfirst($className) . "Constructor" . $codeGenerator->WK_ucfirst($attribute->signature->name) if $attribute->isStatic;
    567546    return "set" . $codeGenerator->WK_ucfirst(GetJSBuiltinFunctionName($className, $attribute)) if IsJSBuiltin($interface, $attribute);
    568     return "setJS" . $interface->name . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : "");
     547    return "setJS" . $interface->name . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($codeGenerator->IsConstructorType($attribute->signature->idlType) ? "Constructor" : "");
    569548}
    570549
     
    593572        my $specialExists = grep { $_ eq $special } @$specials;
    594573        my $parameters = $function->parameters;
    595         if ($specialExists and scalar(@$parameters) == $numberOfParameters and $parameters->[0]->type eq $firstParameterType) {
     574        if ($specialExists and scalar(@$parameters) == $numberOfParameters and $parameters->[0]->idlType->name eq $firstParameterType) {
    596575            return $function;
    597576        }
     
    636615
    637616    return 1 if InterfaceRequiresAttributesOnInstance($interface);
    638     return 1 if $attribute->signature->type =~ /Constructor$/;
     617    return 1 if $codeGenerator->IsConstructorType($attribute->signature->idlType);
    639618
    640619    # [Unforgeable] attributes should be on the instance.
     
    678657
    679658    # As per Web IDL specification, constructor properties on the ECMAScript global object should not be enumerable.
    680     my $is_global_constructor = $attribute->signature->type =~ /Constructor$/;
     659    my $is_global_constructor = $attribute->signature->idlType->name =~ /Constructor$/;
    681660    push(@specials, "DontEnum") if ($attribute->signature->extendedAttributes->{NotEnumerable} || $is_global_constructor);
    682661    push(@specials, "ReadOnly") if IsReadonly($attribute);
     
    799778sub GetImplClassName
    800779{
    801     my $name = shift;
    802 
    803     my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($name);
     780    my $interface = shift;
     781
     782    my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interface);
    804783    return $svgNativeType if $svgNativeType;
    805784
    806     return $name;
     785    return $interface->name;
    807786}
    808787
     
    836815    my ($interface, $name) = @_;
    837816
    838     my $class = GetImplClassName($interface->name);
     817    my $class = GetImplClassName($interface);
    839818    my $member = $codeGenerator->WK_ucfirst($name);
    840819
     
    856835sub GetEnumerationClassName
    857836{
    858     my ($name, $interface) = @_;
    859 
    860     if ($codeGenerator->HasEnumImplementationNameOverride($name)) {
    861         return $codeGenerator->GetEnumImplementationNameOverride($name);
    862     }
    863 
    864     return $name if $codeGenerator->IsExternalEnumType($name);
     837    my ($type, $interface) = @_;
     838
     839    assert("Not a type") if ref($type) ne "domType";
     840
     841    if ($codeGenerator->HasEnumImplementationNameOverride($type)) {
     842        return $codeGenerator->GetEnumImplementationNameOverride($type);
     843    }
     844
     845    my $name = $type->name;
     846
     847    return $name if $codeGenerator->IsExternalEnumType($type);
    865848    return $name unless defined($interface);
    866849
     
    1000983    my $result = "";
    1001984    foreach my $enumeration (@$enumerations) {
    1002         my $name = $enumeration->name;
    1003 
    1004         my $className = GetEnumerationClassName($name, $interface);
     985        my $className = GetEnumerationClassName($enumeration->type, $interface);
    1005986        my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration);
    1006987        $result .= GenerateEnumerationImplementationContent($enumeration, $className, $interface, $conditionalString);
     
    10371018    my $result = "";
    10381019    foreach my $enumeration (@$enumerations) {
    1039         my $className = GetEnumerationClassName($enumeration->name, $interface);
     1020        my $className = GetEnumerationClassName($enumeration->type, $interface);
    10401021        my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration);
    10411022        $result .= GenerateEnumerationHeaderContent($enumeration, $className, $conditionalString);
     
    10461027sub GetDictionaryClassName
    10471028{
    1048     my ($name, $interface) = @_;
    1049 
    1050     if ($codeGenerator->HasDictionaryImplementationNameOverride($name)) {
    1051         return $codeGenerator->GetDictionaryImplementationNameOverride($name);
    1052     }
    1053 
    1054     return $name if $codeGenerator->IsExternalDictionaryType($name);
     1029    my ($type, $interface) = @_;
     1030
     1031    if ($codeGenerator->HasDictionaryImplementationNameOverride($type)) {
     1032        return $codeGenerator->GetDictionaryImplementationNameOverride($type);
     1033    }
     1034
     1035    my $name = $type->name;
     1036    return $name if $codeGenerator->IsExternalDictionaryType($type);
    10551037    return $name unless defined($interface);
    10561038    return GetNestedClassName($interface, $name);
     
    10631045    my $defaultValue = $signature->default;
    10641046
    1065     if ($codeGenerator->IsEnumType($signature->type)) {
     1047    if ($codeGenerator->IsEnumType($signature->idlType)) {
    10661048        # FIXME: Would be nice to report an error if the value does not have quote marks around it.
    10671049        # FIXME: Would be nice to report an error if the value is not one of the enumeration values.
    1068         my $className = GetEnumerationClassName($signature->type, $interface);
     1050        my $className = GetEnumerationClassName($signature->idlType, $interface);
    10691051        my $enumerationValueName = GetEnumerationValueName(substr($defaultValue, 1, -1));
    10701052        return $className . "::" . $enumerationValueName;
     
    10771059            return "convert<${IDLType}>(state, jsNull());";
    10781060        }
    1079         return "jsNull()" if $signature->type eq "any";
    1080         return "nullptr" if $codeGenerator->IsWrapperType($signature->type) || $codeGenerator->IsTypedArrayType($signature->type);
    1081         return "String()" if $codeGenerator->IsStringType($signature->type);
     1061        return "jsNull()" if $signature->idlType->name eq "any";
     1062        return "nullptr" if $codeGenerator->IsWrapperType($signature->idlType) || $codeGenerator->IsTypedArrayType($signature->idlType);
     1063        return "String()" if $codeGenerator->IsStringType($signature->idlType);
    10821064        return "Nullopt";
    10831065    }
     
    10911073
    10921074    return $defaultValue;
    1093 }
    1094 
    1095 sub ShouldAllowNonFiniteForFloatingPointType
    1096 {
    1097     my $type = shift;
    1098 
    1099     die "Can only be called with floating point types" unless $codeGenerator->IsFloatingPointType($type);
    1100     return $type eq "unrestricted double" || $type eq "unrestricted float";
    1101 }
    1102 
    1103 sub GenerateConversionRuleWithLeadingComma
    1104 {
    1105     my ($interface, $member) = @_;
    1106 
    1107     if ($codeGenerator->IsFloatingPointType($member->type)) {
    1108         return ", " . (ShouldAllowNonFiniteForFloatingPointType($member->type) ? "ShouldAllowNonFinite::Yes" : "ShouldAllowNonFinite::No");
    1109     }
    1110     return ", " . GetIntegerConversionConfiguration($member) if $codeGenerator->IsIntegerType($member->type);
    1111     return "";
    11121075}
    11131076
     
    11341097    foreach my $dictionary (@$allDictionaries) {
    11351098        $headerIncludes{$interface->name . ".h"} = 1;
    1136         my $className = GetDictionaryClassName($dictionary->name, $interface);
     1099        my $className = GetDictionaryClassName($dictionary->type, $interface);
    11371100        my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
    11381101        $result .= GenerateDictionaryHeaderContent($dictionary, $className, $conditionalString);
     
    11791142    my @dictionaries;
    11801143    push(@dictionaries, $dictionary);
    1181     my $parentName = $dictionary->parent;
    1182     while (defined($parentName)) {
    1183         my $parentDictionary = $codeGenerator->GetDictionaryByName($parentName);
    1184         assert("Unable to find definition for dictionary named '" . $parentName . "'!") unless defined($parentDictionary);
     1144    my $parentType = $dictionary->parentType;
     1145    while (defined($parentType)) {
     1146        my $parentDictionary = $codeGenerator->GetDictionaryByType($parentType);
     1147        assert("Unable to find definition for dictionary named '" . $parentType->name . "'!") unless defined($parentDictionary);
    11851148        unshift(@dictionaries, $parentDictionary);
    1186         $parentName = $parentDictionary->parent;
     1149        $parentType = $parentDictionary->parentType;
    11871150    }
    11881151
     
    12451208    my $result = "";
    12461209    foreach my $dictionary (@$allDictionaries) {
    1247         my $className = GetDictionaryClassName($dictionary->name, $interface);
     1210        my $className = GetDictionaryClassName($dictionary->type, $interface);
    12481211        my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
    12491212        $result .= GenerateDictionaryImplementationContent($dictionary, $className, $interface, $conditionalString);
     
    13181281    $headerIncludes{"SVGElement.h"} = 1 if $className =~ /^JSSVG/;
    13191282
    1320     my $implType = GetImplClassName($interfaceName);
    1321     my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interfaceName);
     1283    my $implType = GetImplClassName($interface);
     1284    my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interface);
    13221285    my $svgPropertyOrListPropertyType;
    13231286    $svgPropertyOrListPropertyType = $svgPropertyType if $svgPropertyType;
     
    13301293    push(@headerContent, "\nnamespace WebCore {\n\n");
    13311294
    1332     if ($codeGenerator->IsSVGAnimatedType($interfaceName)) {
     1295    if ($codeGenerator->IsSVGAnimatedType($interface->type)) {
    13331296        $headerIncludes{"$interfaceName.h"} = 1;
    13341297    } else {
    13351298        # Implementation class forward declaration
    13361299        if (IsDOMGlobalObject($interface)) {
    1337             AddClassForwardIfNeeded($interfaceName) unless $svgPropertyOrListPropertyType;
    1338         }
    1339     }
    1340 
    1341     AddClassForwardIfNeeded("JSDOMWindowShell") if $interfaceName eq "DOMWindow";
     1300            AddClassForwardIfNeeded($interface->type) unless $svgPropertyOrListPropertyType;
     1301        }
     1302    }
     1303
     1304    push(@headerContent, "class JSDOMWindowShell;\n\n") if $interfaceName eq "DOMWindow";
    13421305
    13431306    my $exportMacro = GetExportMacroForJSClass($interface);
     
    13681331        push(@headerContent, "    }\n\n");
    13691332    } elsif ($interface->extendedAttributes->{MasqueradesAsUndefined}) {
    1370         AddIncludesForTypeInHeader($implType) unless $svgPropertyOrListPropertyType;
     1333        AddIncludesForImplementationTypeInHeader($implType) unless $svgPropertyOrListPropertyType;
    13711334        push(@headerContent, "    static $className* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<$implType>&& impl)\n");
    13721335        push(@headerContent, "    {\n");
     
    13841347        push(@headerContent, "    }\n\n"); 
    13851348    } else {
    1386         AddIncludesForTypeInHeader($implType) unless $svgPropertyOrListPropertyType;
     1349        AddIncludesForImplementationTypeInHeader($implType) unless $svgPropertyOrListPropertyType;
    13871350        push(@headerContent, "    static $className* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<$implType>&& impl)\n");
    13881351        push(@headerContent, "    {\n");
     
    14051368    # JSValue to implementation type
    14061369    if (ShouldGenerateToWrapped($hasParent, $interface)) {
    1407         my $nativeType = GetNativeType($interface, $implType);
     1370        my $nativeType = GetNativeType($interface, $interface->type);
    14081371        if ($interface->name eq "XPathNSResolver") {
    14091372            push(@headerContent, "    static $nativeType toWrapped(JSC::ExecState&, JSC::JSValue);\n");
     
    18191782        }, 0);
    18201783        for my $dictionary (@$dictionaries) {
    1821             my $parentName = $dictionary->parent;
    1822             while (defined($parentName)) {
    1823                 push(@ancestors, $parentName) if $codeGenerator->IsExternalDictionaryType($parentName);
    1824                 my $parentDictionary = $codeGenerator->GetDictionaryByName($parentName);
    1825                 assert("Unable to find definition for dictionary named '" . $parentName . "'!") unless defined($parentDictionary);
    1826                 $parentName = $parentDictionary->parent;
     1784            my $parentType = $dictionary->parentType;
     1785            while (defined($parentType)) {
     1786                push(@ancestors, $parentType->name) if $codeGenerator->IsExternalDictionaryType($parentType);
     1787                my $parentDictionary = $codeGenerator->GetDictionaryByType($parentType);
     1788                assert("Unable to find definition for dictionary named '" . $parentType->name . "'!") unless defined($parentDictionary);
     1789                $parentType = $parentDictionary->parentType;
    18271790            }
    18281791        }
     
    20331996    my $isDictionary = sub {
    20341997        my $type = shift;
    2035         return $type eq "Dictionary" || $codeGenerator->IsDictionaryType($type);
     1998        return $type->name eq "Dictionary" || $codeGenerator->IsDictionaryType($type);
    20361999    };
    20372000    my $isCallbackFunctionOrDictionary = sub {
     
    20612024    return 0 if $idlTypeA->name eq $idlTypeB->name;
    20622025    return 0 if $idlTypeA->name eq "object" or $idlTypeB->name eq "object";
    2063     return 0 if $codeGenerator->IsNumericType($idlTypeA->name) && $codeGenerator->IsNumericType($idlTypeB->name);
    2064     return 0 if $codeGenerator->IsStringOrEnumType($idlTypeA->name) && $codeGenerator->IsStringOrEnumType($idlTypeB->name);
    2065     return 0 if &$isDictionary($idlTypeA->name) && &$isDictionary($idlTypeB->name);
    2066     return 0 if $codeGenerator->IsCallbackInterface($idlTypeA->name) && $codeGenerator->IsCallbackInterface($idlTypeB->name);
    2067     return 0 if &$isCallbackFunctionOrDictionary($idlTypeA->name) && &$isCallbackFunctionOrDictionary($idlTypeB->name);
    2068     return 0 if $codeGenerator->IsSequenceOrFrozenArrayType($idlTypeA->name) && $codeGenerator->IsSequenceOrFrozenArrayType($idlTypeB->name);
     2026    return 0 if $codeGenerator->IsNumericType($idlTypeA) && $codeGenerator->IsNumericType($idlTypeB);
     2027    return 0 if $codeGenerator->IsStringOrEnumType($idlTypeA) && $codeGenerator->IsStringOrEnumType($idlTypeB);
     2028    return 0 if &$isDictionary($idlTypeA) && &$isDictionary($idlTypeB);
     2029    return 0 if $codeGenerator->IsCallbackInterface($idlTypeA) && $codeGenerator->IsCallbackInterface($idlTypeB);
     2030    return 0 if &$isCallbackFunctionOrDictionary($idlTypeA) && &$isCallbackFunctionOrDictionary($idlTypeB);
     2031    return 0 if $codeGenerator->IsSequenceOrFrozenArrayType($idlTypeA) && $codeGenerator->IsSequenceOrFrozenArrayType($idlTypeB);
    20692032    # FIXME: return 0 if $idlTypeA and $idlTypeB are both exception types.
    20702033    return 1;
     
    21632126    my $isDictionaryParameter = sub {
    21642127        my ($idlType, $optionality) = @_;
    2165         return $idlType->name eq "Dictionary" || $codeGenerator->IsDictionaryType($idlType->name);
     2128        return $idlType->name eq "Dictionary" || $codeGenerator->IsDictionaryType($idlType);
    21662129    };
    21672130    my $isNullableOrDictionaryParameterOrUnionContainingOne = sub {
     
    21922155    my $isObjectOrCallbackFunctionParameter = sub {
    21932156        my ($idlType, $optionality) = @_;
    2194         return $idlType->name eq "object" || $codeGenerator->IsFunctionOnlyCallbackInterface($idlType->name);
     2157        return $idlType->name eq "object" || $codeGenerator->IsFunctionOnlyCallbackInterface($idlType);
    21952158    };
    21962159    my $isSequenceOrFrozenArrayParameter = sub {
    21972160        my ($idlType, $optionality) = @_;
    2198         return $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);
     2161        return $codeGenerator->IsSequenceOrFrozenArrayType($idlType);
    21992162    };
    22002163    my $isDictionaryOrObjectOrCallbackInterfaceParameter = sub {
     
    22022165        return 1 if &$isDictionaryParameter($idlType, $optionality);
    22032166        return 1 if $idlType->name eq "object";
    2204         return 1 if $codeGenerator->IsCallbackInterface($idlType->name) && !$codeGenerator->IsFunctionOnlyCallbackInterface($idlType->name);
     2167        return 1 if $codeGenerator->IsCallbackInterface($idlType) && !$codeGenerator->IsFunctionOnlyCallbackInterface($idlType);
    22052168        return 0;
    22062169    };
     
    22112174    my $isNumericParameter = sub {
    22122175        my ($idlType, $optionality) = @_;
    2213         return $codeGenerator->IsNumericType($idlType->name);
     2176        return $codeGenerator->IsNumericType($idlType);
    22142177    };
    22152178    my $isStringOrEnumParameter = sub {
    22162179        my ($idlType, $optionality) = @_;
    2217         return $codeGenerator->IsStringOrEnumType($idlType->name);
     2180        return $codeGenerator->IsStringOrEnumType($idlType);
    22182181    };
    22192182    my $isAnyParameter = sub {
     
    22612224                my @idlSubtypes = $idlType->isUnion ? GetFlattenedMemberTypes($idlType) : ( $idlType );
    22622225                for my $idlSubtype (@idlSubtypes) {
    2263                     my $type = $idlSubtype->name;
    2264                     if ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type)) {
    2265                         if ($type eq "DOMWindow") {
     2226                    if ($codeGenerator->IsWrapperType($idlSubtype) || $codeGenerator->IsTypedArrayType($idlSubtype)) {
     2227                        if ($idlSubtype->name eq "DOMWindow") {
    22662228                            AddToImplIncludes("JSDOMWindowShell.h");
    22672229                            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && (asObject(distinguishingArg)->inherits(JSDOMWindowShell::info()) || asObject(distinguishingArg)->inherits(JSDOMWindow::info()))");
    22682230                        } else {
    2269                             &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JS${type}::info())");
     2231                            &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JS" . $idlSubtype->name . "::info())");
    22702232                        }
    22712233                    }
     
    23682330{
    23692331    my $interface = shift;
     2332
    23702333    my $interfaceName = $interface->name;
    2371     $interfaceName = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) if $codeGenerator->IsSVGTypeNeedingTearOff($interfaceName);
     2334    $interfaceName = $codeGenerator->GetSVGTypeNeedingTearOffForType($interface->type) if $codeGenerator->IsSVGTypeNeedingTearOffForType($interface->type);
    23722335    return $interfaceName;
    23732336}
     
    25322495{
    25332496    my $indexedGetterFunction = shift;
    2534     return "jsStringOrUndefined(state, thisObject->wrapped().item(index))" if $indexedGetterFunction->signature->type eq "DOMString";
     2497   
     2498    # FIXME: Should this work for all string types?
     2499    return "jsStringOrUndefined(state, thisObject->wrapped().item(index))" if $indexedGetterFunction->signature->idlType->name eq "DOMString";
    25352500    return "toJS(state, thisObject->globalObject(), thisObject->wrapped().item(index))";
    25362501}
     
    26162581    $implIncludes{"<runtime/PropertyNameArray.h>"} = 1 if $indexedGetterFunction;
    26172582
    2618     my $implType = GetImplClassName($interfaceName);
     2583    my $implType = GetImplClassName($interface);
    26192584
    26202585    AddJSBuiltinIncludesIfNeeded($interface);
     
    29232888    push(@implContent, ", CREATE_METHOD_TABLE($className) };\n\n");
    29242889
    2925     my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interfaceName);
     2890    my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interface);
    29262891    my $svgPropertyOrListPropertyType;
    29272892    $svgPropertyOrListPropertyType = $svgPropertyType if $svgPropertyType;
     
    29302895    # Constructor
    29312896    if ($interfaceName eq "DOMWindow") {
    2932         AddIncludesForTypeInImpl("JSDOMWindowShell");
     2897        AddIncludesForImplementationTypeInImpl("JSDOMWindowShell");
    29332898        push(@implContent, "${className}::$className(VM& vm, Structure* structure, Ref<$implType>&& impl, JSDOMWindowShell* shell)\n");
    29342899        push(@implContent, "    : $parentClassName(vm, structure, WTFMove(impl), shell)\n");
     
    29362901        push(@implContent, "}\n\n");
    29372902    } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
    2938         AddIncludesForTypeInImpl($interfaceName);
     2903        AddIncludesForImplementationTypeInImpl($interfaceName);
    29392904        push(@implContent, "${className}::$className(VM& vm, Structure* structure, Ref<$implType>&& impl)\n");
    29402905        push(@implContent, "    : $parentClassName(vm, structure, WTFMove(impl))\n");
     
    30803045
    30813046            if ($indexedGetterFunction) {
    3082                 if ($indexedGetterFunction->signature->type eq "DOMString") {
     3047                # FIXME: Should this work for all string types?
     3048                if ($indexedGetterFunction->signature->idlType->name eq "DOMString") {
    30833049                    push(@implContent, "    if (LIKELY(index <= MAX_ARRAY_INDEX)) {\n");
    30843050                } else {
     
    31593125
    31603126            my $name = $attribute->signature->name;
    3161             my $type = $attribute->signature->type;
     3127            my $idlType = $attribute->signature->idlType;
    31623128            my $getFunctionName = GetAttributeGetterName($interface, $className, $attribute);
    31633129            my $implGetterFunctionName = $codeGenerator->WK_lcfirst($attribute->signature->extendedAttributes->{ImplementedAs} || $name);
     
    31693135            push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString;
    31703136
    3171             if (!$attribute->isStatic || $attribute->signature->type =~ /Constructor$/) {
     3137            if (!$attribute->isStatic || $codeGenerator->IsConstructorType($idlType)) {
    31723138                my $templateParameters = "${getFunctionName}Getter";
    31733139                if ($attribute->signature->extendedAttributes->{LenientThis}) {
     
    32083174
    32093175            # Global constructors can be disabled at runtime.
    3210             if ($attribute->signature->type =~ /Constructor$/) {
     3176            if ($codeGenerator->IsConstructorType($idlType)) {
    32113177                if ($attribute->signature->extendedAttributes->{EnabledBySetting}) {
    32123178                    AddToImplIncludes("Frame.h");
     
    32433209                push(@implContent, "    InputCursor& cursor = globalObject->inputCursor();\n");
    32443210
    3245                 my $nativeType = GetNativeType($interface, $type);
    3246                 my $memoizedType = GetNativeTypeForMemoization($interface, $type);
     3211                my $nativeType = GetNativeType($interface, $idlType);
     3212                my $memoizedType = GetNativeTypeForMemoization($interface, $idlType);
    32473213                my $exceptionCode = $getterMayThrowLegacyException ? "ec" : "0";
    32483214                push(@implContent, "    static NeverDestroyed<const AtomicString> bindingName(\"$interfaceName.$name\", AtomicString::ConstructFromLiteral);\n");
     
    32743240                push(@implContent, "    auto& impl = thisObject.wrapped();\n");
    32753241                push(@implContent, "    return shouldAllowAccessToNode(&state, impl." . $attribute->signature->name . "()) ? " . NativeToJSValueUsingReferences($attribute->signature, 0, $interface, "impl.$implGetterFunctionName()", "thisObject") . " : jsNull();\n");
    3276             } elsif ($type eq "EventHandler") {
     3242            } elsif ($idlType->name eq "EventHandler") {
    32773243                $implIncludes{"EventNames.h"} = 1;
    32783244                my $getter = $attribute->signature->extendedAttributes->{WindowEventHandler} ? "windowEventHandlerAttribute"
     
    32813247                my $eventName = EventHandlerAttributeEventName($attribute);
    32823248                push(@implContent, "    return $getter(thisObject.wrapped(), $eventName);\n");
    3283             } elsif ($attribute->signature->type =~ /Constructor$/) {
    3284                 my $constructorType = $attribute->signature->type;
     3249            } elsif ($codeGenerator->IsConstructorType($attribute->signature->idlType)) {
     3250                my $constructorType = $attribute->signature->idlType->name;
    32853251                $constructorType =~ s/Constructor$//;
    32863252                # When Constructor attribute is used by DOMWindow.idl, it's correct to pass thisObject as the global object
     
    33313297                    my $jsType = NativeToJSValueUsingReferences($attribute->signature, 0, $interface, "${functionName}(" . join(", ", @arguments) . ")", "thisObject");
    33323298                    push(@implContent, "    auto& impl = thisObject.wrapped();\n") if !$attribute->isStatic;
    3333                     if ($codeGenerator->IsSVGAnimatedType($type)) {
     3299                    if ($codeGenerator->IsSVGAnimatedType($idlType)) {
    33343300                        push(@implContent, "    auto obj = $jsType;\n");
    33353301                        push(@implContent, "    JSValue result = toJS(&state, thisObject.globalObject(), obj.get());\n");
     
    34793445
    34803446            my $name = $attribute->signature->name;
    3481             my $type = $attribute->signature->type;
     3447            my $idlType = $attribute->signature->idlType;
    34823448            my $putFunctionName = GetAttributeSetterName($interface, $className, $attribute);
    34833449            my $implSetterFunctionName = $codeGenerator->WK_ucfirst($name);
     
    35333499                push(@implContent, "    thisObject.set$implSetterFunctionName(state, value);\n");
    35343500                push(@implContent, "    return true;\n");
    3535             } elsif ($type eq "EventHandler") {
     3501            } elsif ($idlType->name eq "EventHandler") {
    35363502                $implIncludes{"JSEventListener.h"} = 1;
    35373503                my $eventName = EventHandlerAttributeEventName($attribute);
     
    35483514                }
    35493515                push(@implContent, "    return true;\n");
    3550             } elsif ($type =~ /Constructor$/) {
    3551                 my $constructorType = $type;
     3516            } elsif ($codeGenerator->IsConstructorType($idlType)) {
     3517                my $constructorType = $idlType->name;
    35523518                $constructorType =~ s/Constructor$//;
    35533519                # $constructorType ~= /Constructor$/ indicates that it is NamedConstructor.
     
    35713537                    if ($putForwards) {
    35723538                        my $implGetterFunctionName = $codeGenerator->WK_lcfirst($attribute->signature->extendedAttributes->{ImplementedAs} || $name);
    3573                         my $forwardedAttribute = $codeGenerator->GetAttributeFromInterface($interface, $type, $putForwards);
     3539                        my $forwardedAttribute = $codeGenerator->GetAttributeFromInterface($interface, $idlType->name, $putForwards);
    35743540
    35753541                        if ($forwardedAttribute->signature->extendedAttributes->{CEReactions}) {
     
    35803546                        }
    35813547
     3548                        my $typeName = $idlType->name;
    35823549                        if ($attribute->signature->isNullable) {
    3583                             push(@implContent, "    RefPtr<${type}> forwardedImpl = thisObject.wrapped().${implGetterFunctionName}();\n");
     3550                            push(@implContent, "    RefPtr<${typeName}> forwardedImpl = thisObject.wrapped().${implGetterFunctionName}();\n");
    35843551                            push(@implContent, "    if (!forwardedImpl)\n");
    35853552                            push(@implContent, "        return false;\n");
     
    35873554                        } else {
    35883555                            # Attribute is not nullable, the implementation is expected to return a reference.
    3589                             push(@implContent, "    Ref<${type}> forwardedImpl = thisObject.wrapped().${implGetterFunctionName}();\n");
     3556                            push(@implContent, "    Ref<${typeName}> forwardedImpl = thisObject.wrapped().${implGetterFunctionName}();\n");
    35903557                            push(@implContent, "    auto& impl = forwardedImpl.get();\n");
    35913558                        }
    35923559                        $attribute = $forwardedAttribute;
    3593                         $type = $attribute->signature->type;
     3560                        $idlType = $attribute->signature->idlType;
    35943561                    } else {
    35953562                        push(@implContent, "    auto& impl = thisObject.wrapped();\n");
     
    36023569
    36033570                my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $attribute->signature, "value", $attribute->signature->extendedAttributes->{Conditional}, "&state", "state", "thisObject");
    3604                 if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type))) {
     3571                if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($idlType) || $codeGenerator->IsTypedArrayType($idlType))) {
    36053572                    $implIncludes{"<runtime/Error.h>"} = 1;
    36063573                    push(@implContent, "    " . GetNativeTypeFromSignature($interface, $attribute->signature) . " nativeValue = nullptr;\n");
     
    36093576                    push(@implContent, "        RETURN_IF_EXCEPTION(throwScope, false);\n") if $mayThrowException;
    36103577                    push(@implContent, "        if (UNLIKELY(!nativeValue)) {\n");
    3611                     push(@implContent, "            throwAttributeTypeError(state, throwScope, \"$visibleInterfaceName\", \"$name\", \"$type\");\n");
     3578                    push(@implContent, "            throwAttributeTypeError(state, throwScope, \"$visibleInterfaceName\", \"$name\", \"" . $idlType->name . "\");\n");
    36123579                    push(@implContent, "            return false;\n");
    36133580                    push(@implContent, "        }\n");
     
    36183585                }
    36193586
    3620                 if ($codeGenerator->IsEnumType($type)) {
     3587                if ($codeGenerator->IsEnumType($idlType)) {
    36213588                    push (@implContent, "    if (UNLIKELY(!nativeValue))\n");
    36223589                    push (@implContent, "        return false;\n");
     
    36253592                if ($shouldPassByReference) {
    36263593                    push(@implContent, "    if (UNLIKELY(!nativeValue)) {\n");
    3627                     push(@implContent, "        throwAttributeTypeError(state, throwScope, \"$visibleInterfaceName\", \"$name\", \"$type\");\n");
     3594                    push(@implContent, "        throwAttributeTypeError(state, throwScope, \"$visibleInterfaceName\", \"$name\", \"" . $idlType->name . "\");\n");
    36283595                    push(@implContent, "        return false;\n");
    36293596                    push(@implContent, "    }\n");
     
    36613628                    my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
    36623629
    3663                     if ($codeGenerator->IsTypedArrayType($type) and not $type eq "ArrayBuffer") {
     3630                    if ($codeGenerator->IsTypedArrayType($idlType) and not $idlType->name eq "ArrayBuffer") {
    36643631                        push(@arguments, "nativeValue.get()");
    3665                     } elsif ($codeGenerator->IsEnumType($type)) {
     3632                    } elsif ($codeGenerator->IsEnumType($idlType)) {
    36663633                        push(@arguments, "nativeValue.value()");
    36673634                    } else {
     
    37523719            next if $isCustom && $isOverloaded && $function->{overloadIndex} > 1;
    37533720
    3754             AddIncludesForTypeInImpl($function->signature->type) unless $isCustom or IsReturningPromise($function);
     3721            AddToImplIncludesForIDLType($function->signature->idlType) unless $isCustom or IsReturningPromise($function);
    37553722
    37563723            my $functionName = GetFunctionName($interface, $className, $function);
     
    39503917
    39513918    if ($indexedGetterFunction) {
    3952         $implIncludes{"URL.h"} = 1 if $indexedGetterFunction->signature->type eq "DOMString";
     3919        # FIXME: Should this work for all string types.
     3920        $implIncludes{"URL.h"} = 1 if $indexedGetterFunction->signature->idlType->name eq "DOMString";
    39533921        if ($interfaceName =~ /^HTML\w*Collection$/ or $interfaceName eq "RadioNodeList") {
    39543922            $implIncludes{"JSNode.h"} = 1;
     
    43014269sub WillConvertUndefinedToDefaultParameterValue
    43024270{
    4303     my $parameterType = shift;
    4304     my $defaultValue = shift;
    4305 
    4306     my $automaticallyGeneratedDefaultValue = $automaticallyGeneratedDefaultValues{$parameterType};
     4271    my ($parameterType, $defaultValue) = @_;
     4272
     4273    my $automaticallyGeneratedDefaultValue = $automaticallyGeneratedDefaultValues{$parameterType->name};
    43074274    return 1 if defined $automaticallyGeneratedDefaultValue && $automaticallyGeneratedDefaultValue eq $defaultValue;
    43084275
     
    43504317    my $argumentIndex = 0;
    43514318    foreach my $parameter (@{$function->parameters}) {
    4352         my $type = $parameter->type;
    43534319        my $idlType = $parameter->idlType;
    43544320
    4355         die "Optional parameters of non-nullable wrapper types are not supported" if $parameter->isOptional && !$parameter->isNullable && $codeGenerator->IsWrapperType($type);
     4321        die "Optional parameters of non-nullable wrapper types are not supported" if $parameter->isOptional && !$parameter->isNullable && $codeGenerator->IsWrapperType($idlType);
    43564322        die "Optional parameters preceding variadic parameters are not supported" if ($parameter->isOptional &&  @{$function->parameters}[$numParameters - 1]->isVariadic);
    43574323
    43584324        if ($parameter->isOptional && !defined($parameter->default)) {
    43594325            # As per Web IDL, optional dictionary parameters are always considered to have a default value of an empty dictionary, unless otherwise specified.
    4360             $parameter->default("[]") if $type eq "Dictionary" or $codeGenerator->IsDictionaryType($type);
     4326            $parameter->default("[]") if $idlType->name eq "Dictionary" or $codeGenerator->IsDictionaryType($idlType);
    43614327
    43624328            # We use undefined as default value for optional parameters of type 'any' unless specified otherwise.
    4363             $parameter->default("undefined") if $type eq "any";
     4329            $parameter->default("undefined") if $idlType->name eq "any";
    43644330
    43654331            # We use the null string as default value for parameters of type DOMString unless specified otherwise.
    4366             $parameter->default("null") if $codeGenerator->IsStringType($type);
     4332            $parameter->default("null") if $codeGenerator->IsStringType($idlType);
    43674333
    43684334            # As per Web IDL, passing undefined for a nullable parameter is treated as null. Therefore, use null as
     
    43714337
    43724338            # For callback parameters, the generated bindings treat undefined as null, so use null as implicit default value.
    4373             $parameter->default("null") if $codeGenerator->IsCallbackInterface($type);
     4339            $parameter->default("null") if $codeGenerator->IsCallbackInterface($idlType);
    43744340        }
    43754341
     
    43774343        my $value = $name;
    43784344
    4379         if ($codeGenerator->IsCallbackInterface($type)) {
    4380             my $callbackClassName = GetCallbackClassName($type);
     4345        if ($codeGenerator->IsCallbackInterface($idlType)) {
     4346            my $callbackClassName = GetCallbackClassName($idlType->name);
     4347            my $typeName = $idlType->name;
    43814348            $implIncludes{"$callbackClassName.h"} = 1;
    43824349            if ($parameter->isOptional) {
    4383                 push(@$outputArray, "    RefPtr<$type> $name;\n");
     4350                push(@$outputArray, "    RefPtr<$typeName> $name;\n");
    43844351                push(@$outputArray, "    if (!state->argument($argumentIndex).isUndefinedOrNull()) {\n");
    4385                 if ($codeGenerator->IsFunctionOnlyCallbackInterface($type)) {
     4352                if ($codeGenerator->IsFunctionOnlyCallbackInterface($idlType)) {
    43864353                    push(@$outputArray, "        if (!state->uncheckedArgument($argumentIndex).isFunction())\n");
    43874354                } else {
     
    43984365            } else {
    43994366                die "CallbackInterface does not support Variadic parameter" if $parameter->isVariadic;
    4400                 if ($codeGenerator->IsFunctionOnlyCallbackInterface($type)) {
     4367                if ($codeGenerator->IsFunctionOnlyCallbackInterface($idlType)) {
    44014368                    push(@$outputArray, "    if (UNLIKELY(!state->uncheckedArgument($argumentIndex).isFunction()))\n");
    44024369                } else {
     
    44224389            $value = "WTFMove($name.arguments.value())";
    44234390
    4424         } elsif ($codeGenerator->IsEnumType($type)) {
    4425             my $className = GetEnumerationClassName($type, $interface);
     4391        } elsif ($codeGenerator->IsEnumType($idlType)) {
     4392            my $className = GetEnumerationClassName($idlType, $interface);
    44264393
    44274394            $implIncludes{"<runtime/Error.h>"} = 1;
     
    44554422            }
    44564423
    4457             $implIncludes{"JS$className.h"} = 1 if $codeGenerator->IsExternalEnumType($type);
     4424            $implIncludes{"JS$className.h"} = 1 if $codeGenerator->IsExternalEnumType($idlType);
    44584425            push(@$outputArray, "$indent    $defineOptionalValue = parseEnumeration<$className>(*state, ${name}Value);\n");
    44594426            push(@$outputArray, "$indent    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n");
     
    44674434            my $inner;
    44684435            my $nativeType = GetNativeTypeFromSignature($interface, $parameter);
    4469             my $isTearOff = $codeGenerator->IsSVGTypeNeedingTearOff($type) && $interfaceName !~ /List$/;
     4436            my $isTearOff = $codeGenerator->IsSVGTypeNeedingTearOffForType($idlType) && $interfaceName !~ /List$/;
    44704437            my $shouldPassByReference = $isTearOff || ShouldPassWrapperByReference($parameter, $interface);
    44714438
     
    44734440            my $argumentLookupMethod = $parameter->isOptional ? "argument" : "uncheckedArgument";
    44744441
    4475             if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type))) {
     4442            if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($idlType) || $codeGenerator->IsTypedArrayType($idlType))) {
    44764443                $implIncludes{"<runtime/Error.h>"} = 1;
    44774444                my $checkedArgument = "state->$argumentLookupMethod($argumentIndex)";
     
    44834450                push(@$outputArray, "        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
    44844451                push(@$outputArray, "        if (UNLIKELY(!$name))\n");
    4485                 push(@$outputArray, "            return throwArgumentTypeError(*state, throwScope, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n");
     4452                push(@$outputArray, "            return throwArgumentTypeError(*state, throwScope, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"" . $idlType->name . "\");\n");
    44864453                push(@$outputArray, "    }\n");
    44874454                $value = "WTFMove($name)";
    44884455            } else {
    4489                 if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($type, $parameter->default)) {
     4456                if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($idlType, $parameter->default)) {
    44904457                    my $defaultValue = $parameter->default;
    44914458
    44924459                    # String-related optimizations.
    4493                     if ($codeGenerator->IsStringType($type)) {
     4460                    if ($codeGenerator->IsStringType($idlType)) {
    44944461                        my $useAtomicString = $parameter->extendedAttributes->{AtomicString};
    44954462                        if ($defaultValue eq "null") {
     
    45234490            if ($shouldPassByReference) {
    45244491                push(@$outputArray, "    if (UNLIKELY(!$name))\n");
    4525                 push(@$outputArray, "        return throwArgumentTypeError(*state, throwScope, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n");
     4492                push(@$outputArray, "        return throwArgumentTypeError(*state, throwScope, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"" . $idlType->name . "\");\n");
    45264493                $value = $isTearOff ? "$name->propertyReference()" : "*$name";
    45274494            }
    45284495
    4529             if ($codeGenerator->IsTypedArrayType($type) and $parameter->type ne "ArrayBuffer") {
     4496            if ($codeGenerator->IsTypedArrayType($idlType) and $idlType->name ne "ArrayBuffer") {
    45304497               $value = $shouldPassByReference ? "$name.releaseNonNull()" : "WTFMove($name)";
    4531             } elsif ($codeGenerator->IsDictionaryType($type)) {
     4498            } elsif ($codeGenerator->IsDictionaryType($idlType)) {
    45324499                $value = "WTFMove($name)";
    45334500            }
     
    45404507    push @arguments, GenerateReturnParameters($function);
    45414508    my $functionString = "$functionName(" . join(", ", @arguments) . ")";
    4542     $functionString = "propagateException(*state, throwScope, $functionString)" if $function->signature->type && $function->signature->type eq "void" && $function->signature->extendedAttributes->{MayThrowException};
     4509    $functionString = "propagateException(*state, throwScope, $functionString)" if $function->signature->idlType && $function->signature->idlType->name eq "void" && $function->signature->extendedAttributes->{MayThrowException};
    45434510
    45444511    return ($functionString, scalar @arguments);
     
    45584525{
    45594526    my ($object, $dictionary, $className, $enumerations) = @_;
    4560 
    4561     my $dictionaryName = $dictionary->name;
    45624527
    45634528    # - Add default header template and header protection.
     
    45784543    if ($writeDependencies) {
    45794544        my @ancestors;
    4580         my $parentName = $dictionary->parent;
    4581         while (defined($parentName)) {
    4582             push(@ancestors, $parentName) if $codeGenerator->IsExternalDictionaryType($parentName);
    4583             my $parentDictionary = $codeGenerator->GetDictionaryByName($parentName);
    4584             assert("Unable to find definition for dictionary named '" . $parentName . "'!") unless $parentDictionary;
    4585             $parentName = $parentDictionary->parent;
     4545        my $parentType = $dictionary->parentType;
     4546        while (defined($parentType)) {
     4547            push(@ancestors, $parentType->name) if $codeGenerator->IsExternalDictionaryType($parentType);
     4548            my $parentDictionary = $codeGenerator->GetDictionaryByType($parentType);
     4549            assert("Unable to find definition for dictionary named '" . $parentType->name . "'!") unless $parentDictionary;
     4550            $parentType = $parentDictionary->parentType;
    45864551        }
    45874552        push(@depsContent, "$className.h : ", join(" ", map { "$_.idl" } @ancestors), "\n");
     
    46494614            my @arguments = ();
    46504615            foreach my $parameter (@{$function->parameters}) {
    4651                 push(@arguments, GetNativeTypeForCallbacks($interface, $parameter->type) . " " . $parameter->name);
    4652             }
    4653             push(@headerContent, "    virtual " . GetNativeTypeForCallbacks($interface, $function->signature->type) . " " . $function->signature->name . "(" . join(", ", @arguments) . ");\n");
     4616                push(@arguments, GetNativeTypeForCallbacks($interface, $parameter->idlType) . " " . $parameter->name);
     4617            }
     4618            push(@headerContent, "    virtual " . GetNativeTypeForCallbacks($interface, $function->signature->idlType) . " " . $function->signature->name . "(" . join(", ", @arguments) . ");\n");
    46544619        }
    46554620    }
     
    47814746        foreach my $function (@{$interface->functions}) {
    47824747            my @params = @{$function->parameters};
    4783             if ($function->signature->extendedAttributes->{Custom} || GetNativeType($interface, $function->signature->type) ne "bool") {
     4748            if ($function->signature->extendedAttributes->{Custom} || GetNativeType($interface, $function->signature->idlType) ne "bool") {
    47844749                next;
    47854750            }
    47864751
    4787             AddIncludesForTypeInImpl($function->signature->type);
     4752            AddToImplIncludesForIDLType($function->signature->idlType);
    47884753            my $functionName = $function->signature->name;
    4789             push(@implContent, "\n" . GetNativeTypeForCallbacks($interface, $function->signature->type) . " ${className}::${functionName}(");
     4754            push(@implContent, "\n" . GetNativeTypeForCallbacks($interface, $function->signature->idlType) . " ${className}::${functionName}(");
    47904755
    47914756            my @args = ();
     
    47934758            foreach my $param (@params) {
    47944759                my $paramName = $param->name;
    4795                 AddIncludesForTypeInImpl($param->type, 1);
    4796                 push(@args, GetNativeTypeForCallbacks($interface, $param->type) . " " . $paramName);
     4760                AddToImplIncludesForIDLType($param->idlType, 1);
     4761                push(@args, GetNativeTypeForCallbacks($interface, $param->idlType) . " " . $paramName);
    47974762            }
    47984763            push(@implContent, join(", ", @args));
     
    48624827    my $mayThrowLegacyException = $function->signature->extendedAttributes->{MayThrowLegacyException};
    48634828
    4864     if ($function->signature->type eq "void" || IsReturningPromise($function)) {
     4829    if ($function->signature->idlType->name eq "void" || IsReturningPromise($function)) {
    48654830        if ($nondeterministic) {
    48664831            AddToImplIncludes("<replay/InputCursor.h>", "WEB_REPLAY");
     
    48984863
    48994864            my $nativeType = GetNativeTypeFromSignature($interface, $function->signature);
    4900             my $memoizedType = GetNativeTypeForMemoization($interface, $function->signature->type);
     4865            my $memoizedType = GetNativeTypeForMemoization($interface, $function->signature->idlType);
    49014866            my $bindingName = $interface->name . "." . $function->signature->name;
    49024867            push(@implContent, $indent . "JSValue result;\n");
     
    50535018    my ($interface, $signature) = @_;
    50545019
    5055     return GetNativeType($interface, $signature->type);
     5020    return GetNativeType($interface, $signature->idlType);
    50565021}
    50575022
     
    50825047sub GetNativeVectorType
    50835048{
    5084     my ($interface, $type) = @_;
     5049    my ($type) = @_;
    50855050
    50865051    die "This should only be called for sequence or array types" unless $codeGenerator->IsSequenceOrFrozenArrayType($type);
     
    51705135
    51715136    return $IDLTypes{$idlType->name} if exists $IDLTypes{$idlType->name};
    5172     return "IDLEnumeration<" . GetEnumerationClassName($idlType->name, $interface) . ">" if $codeGenerator->IsEnumType($idlType->name);
    5173     return "IDLDictionary<" . GetDictionaryClassName($idlType->name, $interface) . ">" if $codeGenerator->IsDictionaryType($idlType->name);
    5174     return "IDLSequence<" . GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $codeGenerator->IsSequenceType($idlType->name);
    5175     return "IDLFrozenArray<" . GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $codeGenerator->IsFrozenArrayType($idlType->name);
     5137    return "IDLEnumeration<" . GetEnumerationClassName($idlType, $interface) . ">" if $codeGenerator->IsEnumType($idlType);
     5138    return "IDLDictionary<" . GetDictionaryClassName($idlType, $interface) . ">" if $codeGenerator->IsDictionaryType($idlType);
     5139    return "IDLSequence<" . GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $codeGenerator->IsSequenceType($idlType);
     5140    return "IDLFrozenArray<" . GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $codeGenerator->IsFrozenArrayType($idlType);
    51765141    return "IDLUnion<" . join(", ", GetIDLUnionMemberTypes($interface, $idlType)) . ">" if $idlType->isUnion;
    51775142    return "IDLInterface<" . $idlType->name . ">";
     
    51915156    my ($interface, $type) = @_;
    51925157
    5193     return $nativeType{$type} if exists $nativeType{$type};
     5158    assert("Not a type") if ref($type) ne "domType";
     5159
     5160    my $typeName = $type->name;
     5161
     5162    return $nativeType{$typeName} if exists $nativeType{$typeName};
    51945163
    51955164    return GetEnumerationClassName($type, $interface) if $codeGenerator->IsEnumType($type);
    51965165    return GetDictionaryClassName($type, $interface) if $codeGenerator->IsDictionaryType($type);
    5197 
    5198     my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($type);
     5166    return GetNativeVectorType($type) if $codeGenerator->IsSequenceOrFrozenArrayType($type);
     5167
     5168    my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOffForType($type);
    51995169    return "${tearOffType}*" if $tearOffType;
    52005170
    5201     return "RefPtr<${type}>" if $codeGenerator->IsTypedArrayType($type) and $type ne "ArrayBuffer";
    5202 
    5203     return GetNativeVectorType($interface, $type) if $codeGenerator->IsSequenceOrFrozenArrayType($type);
    5204 
    5205     return "${type}*";
     5171    return "RefPtr<${typeName}>" if $codeGenerator->IsTypedArrayType($type) and $typeName ne "ArrayBuffer";
     5172    return "${typeName}*";
    52065173}
    52075174
    52085175sub ShouldPassWrapperByReference
    52095176{
    5210     my $parameter = shift;
    5211     my $interface = shift;
    5212 
    5213     my $nativeType = GetNativeType($interface, $parameter->type);
     5177    my ($parameter, $interface) = @_;
     5178
     5179    my $nativeType = GetNativeType($interface, $parameter->idlType);
    52145180    return $codeGenerator->ShouldPassWrapperByReference($parameter, $interface) && (substr($nativeType, -1) eq '*' || $nativeType =~ /^RefPtr/);
    52155181}
     
    52195185    my $innerType = shift;
    52205186
    5221     return $nativeType{$innerType} if exists $nativeType{$innerType};
    5222     return "RefPtr<$innerType>";
     5187    my $innerTypeName = $innerType->name;
     5188
     5189    return $nativeType{$innerTypeName} if exists $nativeType{$innerTypeName};
     5190    return "RefPtr<$innerTypeName>";
    52235191}
    52245192
     
    52275195    my ($interface, $type) = @_;
    52285196
    5229     return "RefPtr<SerializedScriptValue>&&" if $type eq "SerializedScriptValue";
     5197    return "RefPtr<SerializedScriptValue>&&" if $type->name eq "SerializedScriptValue";
    52305198    return "const String&" if $codeGenerator->IsStringType($type);
    52315199    return GetNativeType($interface, $type);
     
    52415209sub GetSVGPropertyTypes
    52425210{
    5243     my $implType = shift;
     5211    my $interface = shift;
     5212
     5213    my $interfaceName = $interface->name;
    52445214
    52455215    my $svgPropertyType;
     
    52475217    my $svgNativeType;
    52485218
    5249     return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $implType =~ /SVG/;
    5250 
    5251     $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implType);
     5219    return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $interfaceName =~ /SVG/;
     5220
     5221    $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOffForType($interface->type);
    52525222    return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgNativeType;
    52535223
    5254     my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implType);
     5224    my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOffForType($interface->type);
    52555225    if ($svgNativeType =~ /SVGPropertyTearOff/) {
    52565226        $svgPropertyType = $svgWrappedNativeType;
     
    52795249{
    52805250    my $type = shift;
    5281     return exists $nativeType{$type};
     5251
     5252    return exists $nativeType{$type->name};
    52825253}
    52835254
     
    53105281    return 1 if $idlType->name eq "Date";
    53115282    return 1 if $idlType->name eq "BufferSource";
    5312     return 1 if $codeGenerator->IsIntegerType($idlType->name);
    5313     return 1 if $codeGenerator->IsFloatingPointType($idlType->name);
    5314     return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);
    5315     return 1 if $codeGenerator->IsDictionaryType($idlType->name);
    5316     return 1 if $codeGenerator->IsStringType($idlType->name);
     5283    return 1 if $codeGenerator->IsIntegerType($idlType);
     5284    return 1 if $codeGenerator->IsFloatingPointType($idlType);
     5285    return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType);
     5286    return 1 if $codeGenerator->IsDictionaryType($idlType);
     5287    return 1 if $codeGenerator->IsStringType($idlType);
    53175288    return 0;
    53185289}
     
    53245295    my ($interface, $signature, $value, $conditional, $statePointer, $stateReference, $thisObjectReference) = @_;
    53255296
    5326     my $type = $signature->type;
    53275297    my $idlType = $signature->idlType;
    53285298
     
    53415311        push(@conversionArguments, "$stateReference");
    53425312        push(@conversionArguments, "$value");
    5343         push(@conversionArguments, GetIntegerConversionConfiguration($signature)) if $codeGenerator->IsIntegerType($type);
    5344         push(@conversionArguments, GetStringConversionConfiguration($signature)) if $codeGenerator->IsStringType($type);
     5313        push(@conversionArguments, GetIntegerConversionConfiguration($signature)) if $codeGenerator->IsIntegerType($idlType);
     5314        push(@conversionArguments, GetStringConversionConfiguration($signature)) if $codeGenerator->IsStringType($idlType);
    53455315
    53465316        return ("convert<$IDLType>(" . join(", ", @conversionArguments) . ")", 1);
    53475317    }
    53485318
    5349     if ($type eq "DOMString") {
     5319    if ($idlType->name eq "DOMString") {
    53505320        return ("AtomicString($value.toString($statePointer)->toExistingAtomicString($statePointer))", 1) if $signature->extendedAttributes->{RequiresExistingAtomicString};
    53515321        return ("$value.toString($statePointer)->toAtomicString($statePointer)", 1) if $signature->extendedAttributes->{AtomicString};
     
    53535323    }
    53545324
    5355     if ($type eq "SerializedScriptValue") {
     5325    if ($idlType->name eq "SerializedScriptValue") {
    53565326        AddToImplIncludes("SerializedScriptValue.h", $conditional);
    53575327        return ("SerializedScriptValue::create($stateReference, $value)", 1);
    53585328    }
    53595329
    5360     if ($type eq "Dictionary") {
     5330    if ($idlType->name eq "Dictionary") {
    53615331        AddToImplIncludes("Dictionary.h", $conditional);
    53625332        return ("Dictionary($statePointer, $value)", 0);
    53635333    }
    53645334
    5365     return ("to$type($value)", 1) if $codeGenerator->IsTypedArrayType($type);
    5366    
    5367     if ($codeGenerator->IsEnumType($type)) {
    5368         AddToImplIncludes("JS$type.h", $conditional) if $codeGenerator->IsExternalEnumType($type);
    5369         return ("parseEnumeration<" . GetEnumerationClassName($type, $interface) . ">($stateReference, $value)", 1);
    5370     }
    5371    
    5372     AddToImplIncludes("JS$type.h", $conditional);
     5335    AddToImplIncludesForIDLType($idlType, $conditional);
     5336
     5337    return ("to@{[$idlType->name]}($value)", 1) if $codeGenerator->IsTypedArrayType($idlType);
     5338    return ("parseEnumeration<" . GetEnumerationClassName($idlType, $interface) . ">($stateReference, $value)", 1) if $codeGenerator->IsEnumType($idlType);
    53735339
    53745340    # FIXME: EventListener should be a callback interface.
    5375     return "JSEventListener::create($value, $thisObjectReference, false, currentWorld($statePointer))" if $type eq "EventListener";
    5376 
    5377     my $extendedAttributes = $codeGenerator->getInterfaceExtendedAttributesFromName($type);
    5378     return ("JS${type}::toWrapped($stateReference, $value)", 1) if $type eq "XPathNSResolver";
    5379     return ("JS${type}::toWrapped($value)", 0);
     5341    return "JSEventListener::create($value, $thisObjectReference, false, currentWorld($statePointer))" if $idlType->name eq "EventListener";
     5342
     5343    my $extendedAttributes = $codeGenerator->GetInterfaceExtendedAttributesFromName($idlType->name);
     5344    return ("JS" . $idlType->name . "::toWrapped($stateReference, $value)", 1) if $idlType->name eq "XPathNSResolver";
     5345    return ("JS" . $idlType->name . "::toWrapped($value)", 0);
    53805346}
    53815347
     
    53875353    return 1 if $idlType->name eq "boolean";
    53885354    return 1 if $idlType->name eq "Date";
    5389     return 1 if $codeGenerator->IsIntegerType($idlType->name);
    5390     return 1 if $codeGenerator->IsFloatingPointType($idlType->name);
    5391     return 1 if $codeGenerator->IsStringType($idlType->name);
    5392     return 1 if $codeGenerator->IsEnumType($idlType->name);
     5355    return 1 if $codeGenerator->IsIntegerType($idlType);
     5356    return 1 if $codeGenerator->IsFloatingPointType($idlType);
     5357    return 1 if $codeGenerator->IsStringType($idlType);
     5358    return 1 if $codeGenerator->IsEnumType($idlType);
     5359    return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType);
    53935360    return 1 if $idlType->isUnion;
    5394     return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);
    53955361
    53965362    return 0;
     
    54035369    # FIXME: This should actually check if all the sub-objects of the union need the state.
    54045370    return 1 if $idlType->isUnion;
    5405     return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);
    5406     return 1 if $codeGenerator->IsStringType($idlType->name);
    5407     return 1 if $codeGenerator->IsEnumType($idlType->name);
     5371    return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType);
     5372    return 1 if $codeGenerator->IsStringType($idlType);
     5373    return 1 if $codeGenerator->IsEnumType($idlType);
    54085374    return 1 if $idlType->name eq "Date";
    54095375
     
    54175383    # FIXME: This should actually check if all the sub-objects of the union need the global object.
    54185384    return 1 if $idlType->isUnion;
    5419     return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);
     5385    return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType);
    54205386
    54215387    return 0;
     
    54505416
    54515417    my $conditional = $signature->extendedAttributes->{Conditional};
    5452     my $type = $signature->type;
    54535418    my $idlType = $signature->idlType;
    54545419    my $isNullable = $signature->isNullable;
     
    54575422    # We could instead overload a function to work with optional as well as non-optional numbers, but this
    54585423    # is slightly better because it guarantees we will fail to compile if the IDL file doesn't match the C++.
    5459     if ($signature->extendedAttributes->{Reflect} and ($type eq "unsigned long" or $type eq "unsigned short")) {
     5424    if ($signature->extendedAttributes->{Reflect} and ($idlType->name eq "unsigned long" or $idlType->name eq "unsigned short")) {
    54605425        $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
    54615426        $value = "std::max(0, $value)";
    54625427    }
    54635428
    5464     if ($type eq "any") {
     5429    if ($idlType->name eq "any") {
    54655430        my $returnType = $signature->extendedAttributes->{ImplementationReturnType};
    54665431        if (defined $returnType and ($returnType eq "IDBKeyPath" or $returnType eq "IDBKey")) {
     
    54855450    }
    54865451
    5487     if ($type eq "SerializedScriptValue") {
     5452    if ($idlType->name eq "SerializedScriptValue") {
    54885453        AddToImplIncludes("SerializedScriptValue.h", $conditional);
    54895454        return "$value ? $value->deserialize($stateReference, $globalObject) : jsNull()";
    54905455    }
    54915456
    5492     AddToImplIncludes("StyleProperties.h", $conditional) if $type eq "CSSStyleDeclaration";
    5493     AddToImplIncludes("NameNodeList.h", $conditional) if $type eq "NodeList";
    5494     AddToImplIncludes("JS$type.h", $conditional) if !$codeGenerator->IsTypedArrayType($type);
    5495 
    5496     return $value if $codeGenerator->IsSVGAnimatedType($type);
    5497 
    5498     if ($codeGenerator->IsSVGAnimatedType($interface->name) or ($interface->name eq "SVGViewSpec" and $type eq "SVGTransformList")) {
     5457    AddToImplIncludes("StyleProperties.h", $conditional) if $idlType->name eq "CSSStyleDeclaration";
     5458    AddToImplIncludes("NameNodeList.h", $conditional) if $idlType->name eq "NodeList";
     5459    AddToImplIncludes("JS" . $idlType->name . ".h", $conditional) if !$codeGenerator->IsTypedArrayType($idlType);
     5460
     5461    return $value if $codeGenerator->IsSVGAnimatedType($idlType);
     5462
     5463    if ($codeGenerator->IsSVGAnimatedType($interface->type) or ($interface->name eq "SVGViewSpec" and $idlType->name eq "SVGTransformList")) {
    54995464        # Convert from abstract RefPtr<ListProperty> to real type, so the right toJS() method can be invoked.
    5500         $value = "static_cast<" . GetNativeType($interface, $type) . ">($value.get())";
     5465        $value = "static_cast<" . GetNativeType($interface, $idlType) . ">($value.get())";
    55015466    } elsif ($interface->name eq "SVGViewSpec") {
    55025467        # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked.
    5503         $value = "static_cast<" . GetNativeType($interface, $type) . ">($value)";
    5504     } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $interface->name =~ /List$/) {
    5505         my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($type);
    5506         if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($type) and !$inFunctionCall and not defined $signature->extendedAttributes->{Immutable}) {
     5468        $value = "static_cast<" . GetNativeType($interface, $idlType) . ">($value)";
     5469    } elsif ($codeGenerator->IsSVGTypeNeedingTearOffForType($idlType) and not $interface->type->name =~ /List$/) {
     5470        my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOffForType($idlType);
     5471        if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOffForType($idlType) and !$inFunctionCall and not defined $signature->extendedAttributes->{Immutable}) {
    55075472            my $getter = $value;
    55085473            $getter =~ s/impl\.//;
     
    55115476            my $updateMethod = "&" . $interface->name . "::update" . $codeGenerator->WK_ucfirst($getter);
    55125477
    5513             my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($interface->name);
     5478            my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOffForType($interface->type);
    55145479            if ($selfIsTearOffType) {
    55155480                # FIXME: Why SVGMatrix specifically?
     
    57285693        my $checkType = $include;
    57295694        $checkType =~ s/\.h//;
    5730         next if $codeGenerator->IsSVGAnimatedType($checkType);
     5695        next if $codeGenerator->IsSVGAnimatedTypeName($checkType);
    57315696
    57325697        $include = "\"$include\"" unless $include =~ /^["<]/; # "
     
    60586023    # so we should be able to use our parent's interface object no matter what. However, some of our IDL files (e.g. CanvasRenderingContext2D)
    60596024    # are not valid so we need this check for now.
    6060     if ($interface->parent && !$codeGenerator->getInterfaceExtendedAttributesFromName($interface->parent)->{NoInterfaceObject}) {
     6025    if ($interface->parent && !$codeGenerator->GetInterfaceExtendedAttributesFromName($interface->parent)->{NoInterfaceObject}) {
    60616026        my $parentClassName = "JS" . $interface->parent;
    60626027        push(@$outputArray, "    return ${parentClassName}::getConstructor(vm, &globalObject);\n");
     
    61386103{
    61396104    my $function = shift;
    6140     return $function->signature->type && $function->signature->type eq "Promise";
     6105    return $function->signature->idlType && $function->signature->idlType->name eq "Promise";
    61416106}
    61426107
  • trunk/Source/WebCore/bindings/scripts/IDLParser.pm

    r207829 r208023  
    5555struct( domInterface => {
    5656    name => '$',      # Class identifier
     57    type => '$',      # Class type
    5758    parent => '$',      # Parent class identifier
    58     parents => '@',      # Parent class identifiers (Kept for compatibility with ObjC bindings)
     59    parentType => '$',      # Parent class type
    5960    constants => '@',    # List of 'domConstant'
    6061    functions => '@',    # List of 'domFunction'
     
    9192    direction => '$',   # Variable direction (in or out)
    9293    name => '$',        # Variable name
    93     type => '$',        # Variable type name (DEPRECATED - please use idlType)
    9494    idlType => '$',     # Variable type
    9595    specials => '@',    # Specials
     
    123123# Used to represent string constants
    124124struct( domConstant => {
    125     name => '$',        # DOM Constant identifier
    126     type => '$',        # Type of data
    127     value => '$',       # Constant value
     125    name => '$', # DOM Constant identifier
     126    type => '$', # Type name of data
     127    value => '$', # Constant value
    128128    extendedAttributes => '$', # Extended attributes
    129129});
     
    132132struct( domEnum => {
    133133    name => '$', # Enumeration identifier
     134    type => '$', # Enumeration type
    134135    values => '@', # Enumeration values (list of unique strings)
    135136    extendedAttributes => '$',
     
    137138
    138139struct( domDictionary => {
    139     parent => '$',  # Parent class identifier
    140     name => '$',
     140    name => '$', # Dictionary identifier
     141    type => '$', # Dictionary type
     142    parent => '$',  # Parent identifier
     143    parentType => '$',  # Parent type identifier
    141144    members => '@', # List of 'domSignature'
    142145    extendedAttributes => '$',
     
    361364    my $type = shift;
    362365    $type =~ s/^_//;
     366    return $type;
     367}
     368
     369sub makeSimpleType
     370{
     371    my $typeName = shift;
     372
     373    my $type = domType->new();
     374    $type->name($typeName);
     375   
    363376    return $type;
    364377}
     
    478491    my $numberOfSubtypes = scalar @{$signature->idlType->subtypes};
    479492    if ($numberOfSubtypes) {
    480         my $typeUpdated = 0;
    481    
    482493        for my $i (0..$numberOfSubtypes - 1) {
    483494            my $subtype = @{$signature->idlType->subtypes}[$i];
     
    493504               
    494505                @{$signature->idlType->subtypes}[$i] = $clonedType;
    495                
    496                 $typeUpdated = 1;
    497             }
    498         }
    499 
    500         # FIXME: This can be removed when we use domTypes in the CodeGenerators everywhere.
    501         if ($typeUpdated) {
    502             my $subtype = @{$signature->idlType->subtypes}[0];
    503             my $subtypeName = $subtype->name;
    504 
    505             if ($signature->idlType->name =~ /^sequence</) {
    506                 $signature->idlType->name("sequence<${subtypeName}>");
    507                 $signature->type($signature->idlType->name);
    508             }
    509             if ($signature->idlType->name =~ /^FrozenArray</) {
    510                 $signature->idlType->name("FrozenArray<${subtypeName}>");
    511                 $signature->type($signature->idlType->name);
    512506            }
    513507        }
     
    525519
    526520        $signature->idlType($clonedType);
    527         $signature->type($clonedType->name);
    528521        $signature->isNullable($clonedType->isNullable);
    529522
     
    606599        my $interfaceNameToken = $self->getToken();
    607600        $self->assertTokenType($interfaceNameToken, IdentifierToken);
    608         $interface->name(identifierRemoveNullablePrefix($interfaceNameToken->value()));
    609         my $parents = $self->parseInheritance();
    610         $interface->parents($parents);
    611         $interface->parent($parents->[0]);
     601       
     602        my $name = identifierRemoveNullablePrefix($interfaceNameToken->value());
     603        $interface->name($name);
     604        $interface->type(makeSimpleType($name));
     605
     606        $next = $self->nextToken();
     607        if ($next->value() eq ":") {
     608            my $parent = $self->parseInheritance();
     609            $interface->parent($parent);
     610            $interface->parentType(makeSimpleType($parent));
     611        }
     612
    612613        $self->assertTokenValue($self->getToken(), "{", __LINE__);
    613614        my $interfaceMembers = $self->parseInterfaceMembers();
     
    716717        $dictionary->extendedAttributes($extendedAttributeList);
    717718        $self->assertTokenValue($self->getToken(), "dictionary", __LINE__);
     719
    718720        my $nameToken = $self->getToken();
    719721        $self->assertTokenType($nameToken, IdentifierToken);
    720         $dictionary->name($nameToken->value());
    721         my $parents = $self->parseInheritance();
    722         $dictionary->parent($parents->[0]);
     722
     723        my $name = $nameToken->value();
     724        $dictionary->name($name);
     725        $dictionary->type(makeSimpleType($name));
     726
     727        $next = $self->nextToken();
     728        if ($next->value() eq ":") {
     729            my $parent = $self->parseInheritance();
     730            $dictionary->parent($parent);
     731            $dictionary->parentType(makeSimpleType($parent));
     732        }
     733       
    723734        $self->assertTokenValue($self->getToken(), "{", __LINE__);
    724735        $dictionary->members($self->parseDictionaryMembers());
     
    767778        my $type = $self->parseType();
    768779        $member->idlType($type);
    769         $member->type($type->name);
    770780        $member->isNullable($type->isNullable);
    771781
     
    836846        my $exceptionNameToken = $self->getToken();
    837847        $self->assertTokenType($exceptionNameToken, IdentifierToken);
    838         $interface->name(identifierRemoveNullablePrefix($exceptionNameToken->value()));
     848
     849        my $name = identifierRemoveNullablePrefix($exceptionNameToken->value());
     850        $interface->name($name);
     851        $interface->type(makeSimpleType($name));
    839852        $interface->isException(1);
    840         my $parents = $self->parseInheritance();
    841         $interface->parents($parents);
    842         $interface->parent($parents->[0]);
     853
     854        $next = $self->nextToken();
     855        if ($next->value() eq ":") {
     856            my $parent = $self->parseInheritance();
     857            $interface->parent($parent);
     858            $interface->parentType(makeSimpleType($parent));
     859        }
     860       
    843861        $self->assertTokenValue($self->getToken(), "{", __LINE__);
    844862        my $exceptionMembers = $self->parseExceptionMembers();
     
    876894{
    877895    my $self = shift;
    878     my @parent = ();
    879896
    880897    my $next = $self->nextToken();
    881898    if ($next->value() eq ":") {
    882899        $self->assertTokenValue($self->getToken(), ":", __LINE__);
    883         my $name = $self->parseName();
    884         push(@parent, $name);
    885 
    886         # FIXME: Remove. Was needed for needed for ObjC bindings.
    887         push(@parent, @{$self->parseIdentifiers()});
    888     }
    889     return \@parent;
     900        return $self->parseName();
     901    }
     902    $self->assertUnexpectedToken($next->value(), __LINE__);
    890903}
    891904
     
    901914        my $enumNameToken = $self->getToken();
    902915        $self->assertTokenType($enumNameToken, IdentifierToken);
    903         $enum->name(identifierRemoveNullablePrefix($enumNameToken->value()));
     916        my $name = identifierRemoveNullablePrefix($enumNameToken->value());
     917        $enum->name($name);
     918        $enum->type(makeSimpleType($name));
    904919        $self->assertTokenValue($self->getToken(), "{", __LINE__);
    905920        push(@{$enum->values}, @{$self->parseEnumValueList()});
     
    10161031        my $newDataNode = domConstant->new();
    10171032        $self->assertTokenValue($self->getToken(), "const", __LINE__);
    1018        
    10191033        my $type = $self->parseConstType();
    1020         $newDataNode->type($type->name);
    1021 
     1034        $newDataNode->type($type);
    10221035        my $constNameToken = $self->getToken();
    10231036        $self->assertTokenType($constNameToken, IdentifierToken);
     
    12871300        if (defined ($interface)) {
    12881301            $interface->signature->idlType($returnType);
    1289             $interface->signature->type($returnType->name);
    12901302            $interface->signature->isNullable($returnType->isNullable);
    12911303        }
     
    13271339        my $type = $self->parseType();
    13281340        $newDataNode->signature->idlType($type);
    1329         $newDataNode->signature->type($type->name);
    13301341        $newDataNode->signature->isNullable($type->isNullable);
    13311342
     
    13851396            my $operation = $self->parseOperationRest($extendedAttributeList);
    13861397            $operation->signature->idlType($returnType);
    1387             $operation->signature->type($returnType->name);
    13881398            $operation->signature->isNullable($returnType->isNullable);
    13891399
     
    14071417        if (defined ($interface)) {
    14081418            $interface->signature->idlType($returnType);
    1409             $interface->signature->type($returnType->name);
    14101419            $interface->signature->isNullable($returnType->isNullable);
    14111420            $interface->signature->specials(\@specials);
     
    15051514    my $forEachArgument = domSignature->new();
    15061515    $forEachArgument->name("callback");
    1507     $forEachArgument->type("any");
     1516    $forEachArgument->idlType(makeSimpleType("any"));
    15081517    push(@{$forEachFunction->parameters}, ($forEachArgument));
    15091518
     
    16281637        my $type = $self->parseType();
    16291638        $paramDataNode->idlType($type);
    1630         $paramDataNode->type(identifierRemoveNullablePrefix($type->name));
    16311639        $paramDataNode->isNullable($type->isNullable);
    16321640        $paramDataNode->isOptional(1);
     
    16381646        my $type = $self->parseType();
    16391647        $paramDataNode->idlType($type);
    1640         $paramDataNode->type($type->name);
    16411648        $paramDataNode->isNullable($type->isNullable);
    16421649        $paramDataNode->isOptional(0);
     
    17011708        my $type = $self->parseType();
    17021709        $newDataNode->signature->idlType($type);
    1703         $newDataNode->signature->type($type->name);
    17041710        $newDataNode->signature->isNullable($type->isNullable);
    17051711       
     
    21172123        $self->assertTokenValue($self->getToken(), ">", __LINE__);
    21182124
    2119         # FIXME: This should just be "sequence" when we start using domTypes in the CodeGenerators
    2120         $type->name("sequence<${subtypeName}>");
     2125        $type->name("sequence");
    21212126        push(@{$type->subtypes}, $subtype);
    21222127
     
    21322137        $self->assertTokenValue($self->getToken(), ">", __LINE__);
    21332138
    2134         # FIXME: This should just be "FrozenArray" when we start using domTypes in the CodeGenerators
    2135         $type->name("FrozenArray<${subtypeName}>");
     2139        $type->name("FrozenArray");
    21362140        push(@{$type->subtypes}, $subtype);
    21372141
     
    23502354    # here to determine serializability: https://heycam.github.io/webidl/#idl-serializers
    23512355    my $serializable_types = '^(\(byte|octet|short|unsigned short|long|unsigned long|long long|unsigned long long|float|unrestricted float|double|unrestricted double|boolean|DOMString|ByteString|USVString)$';
    2352     return $attribute->signature->type =~ /$serializable_types/;
     2356    return $attribute->signature->idlType->name =~ /$serializable_types/;
    23532357}
    23542358
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp

    r207912 r208023  
    2727#include "JSDOMConvert.h"
    2828#include "JSNode.h"
    29 #include "Node.h"
    3029#include "wtf/text/AtomicString.h"
    3130#include <runtime/Error.h>
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r207912 r208023  
    2929#include "JSDOMConstructor.h"
    3030#include "JSDOMConvert.h"
    31 #include "TestObj.h"
     31#include "JSTestObj.h"
    3232#include "TestSupplemental.h"
    3333#include <runtime/Error.h>
     
    4141#if ENABLE(Condition11) || ENABLE(Condition12) || ENABLE(Condition22) || ENABLE(Condition23)
    4242#include "JSNode.h"
    43 #include "JSTestObj.h"
    4443#endif
    4544
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r207937 r208023  
    2323
    2424#include "CallbackFunction.h"
    25 #include "DOMStringList.h"
    2625#include "Dictionary.h"
    2726#include "Document.h"
    28 #include "Element.h"
    2927#include "EventNames.h"
    3028#include "ExceptionCode.h"
     
    5755#include "JSXPathNSResolver.h"
    5856#include "RuntimeEnabledFeatures.h"
    59 #include "SVGDocument.h"
    60 #include "SVGPoint.h"
    6157#include "SVGStaticPropertyTearOff.h"
    6258#include "SerializedScriptValue.h"
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp

    r207912 r208023  
    2828#include <runtime/Error.h>
    2929#include <runtime/FunctionPrototype.h>
     30#include <runtime/JSArray.h>
    3031#include <wtf/GetPtr.h>
    3132
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp

    r207912 r208023  
    2727#include "JSDOMConvert.h"
    2828#include "JSNode.h"
    29 #include "Node.h"
    3029#include "wtf/text/AtomicString.h"
    3130#include <runtime/Error.h>
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp

    r207737 r208023  
    3131#include "SerializedScriptValue.h"
    3232#include <runtime/FunctionPrototype.h>
     33#include <runtime/JSArray.h>
    3334#include <wtf/GetPtr.h>
    3435
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp

    r207912 r208023  
    3030#include "JSTestEventTarget.h"
    3131#include "JSTestSubObj.h"
    32 #include "SVGPoint.h"
    3332#include "SerializedScriptValue.h"
    3433#include <runtime/Error.h>
  • trunk/Source/WebCore/html/HTMLEmbedElement.idl

    r206723 r208023  
    2424    CustomCall,
    2525] interface HTMLEmbedElement : HTMLElement {
    26 [Reflect] attribute DOMString align;
    27 [Reflect] attribute DOMString height;
    28 [Reflect] attribute DOMString name;
    29 [Reflect, URL] attribute USVString src;
    30 [Reflect] attribute DOMString type;
    31 [Reflect] attribute DOMString width;
     26    [Reflect] attribute DOMString align;
     27    [Reflect] attribute DOMString height;
     28    [Reflect] attribute DOMString name;
     29    [Reflect, URL] attribute USVString src;
     30    [Reflect] attribute DOMString type;
     31    [Reflect] attribute DOMString width;
    3232
    33 [CheckSecurityForNode, MayThrowLegacyException] SVGDocument getSVGDocument();
     33    [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument();
    3434};
    3535
  • trunk/Source/WebCore/html/HTMLFrameElement.idl

    r206723 r208023  
    3838    readonly attribute DOMWindow contentWindow;
    3939
    40     [CheckSecurityForNode, MayThrowLegacyException] SVGDocument getSVGDocument();
     40    [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument();
    4141
    4242    // FIXME: No other browser has this attribute.
  • trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp

    r207458 r208023  
    113113}
    114114
    115 SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
     115Document* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const
    116116{
    117117    Document* document = contentDocument();
  • trunk/Source/WebCore/html/HTMLFrameOwnerElement.h

    r207458 r208023  
    5050    RenderWidget* renderWidget() const;
    5151
    52     SVGDocument* getSVGDocument(ExceptionCode&) const;
     52    Document* getSVGDocument(ExceptionCode&) const;
    5353
    5454    virtual ScrollbarMode scrollingMode() const { return ScrollbarAuto; }
  • trunk/Source/WebCore/html/HTMLIFrameElement.idl

    r207355 r208023  
    4242    readonly attribute DOMWindow contentWindow;
    4343
    44     [CheckSecurityForNode, MayThrowLegacyException] SVGDocument getSVGDocument();
     44    [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument();
    4545};
    4646
  • trunk/Source/WebCore/html/HTMLObjectElement.idl

    r207426 r208023  
    5151    [CheckSecurityForNode] readonly attribute Document contentDocument;
    5252
    53     [CheckSecurityForNode, MayThrowLegacyException] SVGDocument getSVGDocument();
     53    [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument();
    5454};
    5555
  • trunk/Tools/ChangeLog

    r207998 r208023  
     12016-10-27  Sam Weinig  <sam@webkit.org>
     2
     3        [WebIDL] Move code generators off of domSignature::type and onto domSignature::idlType
     4        https://bugs.webkit.org/show_bug.cgi?id=164089
     5
     6        Reviewed by Alex Christensen.
     7
     8        * DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm:
     9        * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
     10        Update for the removal of domSignature::type, and new signatures of helper predicates.
     11
    1122016-10-27  Commit Queue  <commit-queue@webkit.org>
    213
  • trunk/Tools/DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm

    r206851 r208023  
    6464{
    6565    my ($self, $idlType) = @_;
     66
    6667    return $$self{codeGenerator}->WK_lcfirst(_implementationClassName($idlType)) . "Class";
    6768}
     
    142143    my @contents = ();
    143144
    144     my $idlType = $interface->name;
     145    my $idlType = $interface->type;
    145146    my $className = _className($idlType);
    146147    my $implementationClassName = _implementationClassName($idlType);
     
    209210    my @contents = ();
    210211
    211     my $idlType = $interface->name;
     212    my $idlType = $interface->type;
    212213    my $className = _className($idlType);
    213214    my $implementationClassName = _implementationClassName($idlType);
     
    284285                my @specifiedParameters = @{$function->parameters};
    285286
    286                 $self->_includeHeaders(\%contentsIncludes, $function->signature->type, $function->signature);
     287                $self->_includeHeaders(\%contentsIncludes, $function->signature->idlType, $function->signature);
    287288
    288289                if ($function->signature->extendedAttributes->{"PassContext"}) {
     
    303304            }
    304305           
    305             push(@contents, "    ${functionCall};\n\n") if $function->signature->type eq "void";
     306            push(@contents, "    ${functionCall};\n\n") if $function->signature->idlType->name eq "void";
    306307            push(@contents, "    return " . $self->_returnExpression($function->signature, $functionCall) . ";\n}\n");
    307308        }
     
    311312        push(@contents, "\n// Attributes\n");
    312313        foreach my $attribute (@attributes) {
    313             $self->_includeHeaders(\%contentsIncludes, $attribute->signature->type, $attribute->signature);
     314            $self->_includeHeaders(\%contentsIncludes, $attribute->signature->idlType, $attribute->signature);
    314315
    315316            my $getterName = $self->_getterName($attribute);
     
    368369    my ($self, $attribute) = @_;
    369370
    370     my $signature = $attribute->signature;
    371     my $name = $signature->name;
    372 
    373     return $name;
     371    return $attribute->signature->name;
    374372}
    375373
     
    379377
    380378    return unless defined $idlType;
    381     return if $idlType eq "boolean";
    382     return if $idlType eq "object";
     379    return if $idlType->name eq "boolean";
     380    return if $idlType->name eq "object";
    383381    return if $$self{codeGenerator}->IsNonPointerType($idlType);
    384382    return if $$self{codeGenerator}->IsStringType($idlType);
     
    392390    my ($idlType) = @_;
    393391
    394     return $idlType;
     392    return $idlType->name;
    395393}
    396394
     
    414412{
    415413    my ($interface) = @_;
    416     return $interface->parent;
     414    return $interface->parentType;
    417415}
    418416
     
    423421    return undef unless defined $idlType;
    424422
    425     return "bool" if $idlType eq "boolean";
    426     return "JSValueRef" if $idlType eq "object";
     423    return "bool" if $idlType->name eq "boolean";
     424    return "JSValueRef" if $idlType->name eq "object";
    427425    return "JSRetainPtr<JSStringRef>" if $$self{codeGenerator}->IsStringType($idlType);
    428426    return "double" if $$self{codeGenerator}->IsNonPointerType($idlType);
     
    434432    my ($self, $signature, $argumentName) = @_;
    435433
    436     my $idlType = $signature->type;
     434    my $idlType = $signature->idlType;
    437435
    438436    return "JSValueToBoolean(context, $argumentName)" if $idlType eq "boolean";
    439     return "$argumentName" if $idlType eq "object";
     437    return "$argumentName" if $idlType->name eq "object";
    440438    return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($idlType);
    441439    return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsNonPointerType($idlType);
     
    447445    my ($self, $signature, $variableName, $argumentName, $condition) = @_;
    448446
    449     my $platformType = $self->_platformType($signature->type, $signature);
     447    my $platformType = $self->_platformType($signature->idlType, $signature);
    450448    my $constructor = $self->_platformTypeConstructor($signature, $argumentName);
    451449
     
    475473    my ($self, $signature, $expression) = @_;
    476474
    477     my $returnIDLType = $signature->type;
    478 
    479     return "JSValueMakeUndefined(context)" if $returnIDLType eq "void";
    480     return "JSValueMakeBoolean(context, ${expression})" if $returnIDLType eq "boolean";
    481     return "${expression}" if $returnIDLType eq "object";
     475    my $returnIDLType = $signature->idlType;
     476
     477    return "JSValueMakeUndefined(context)" if $returnIDLType->name eq "void";
     478    return "JSValueMakeBoolean(context, ${expression})" if $returnIDLType->name eq "boolean";
     479    return "${expression}" if $returnIDLType->name eq "object";
    482480    return "JSValueMakeNumber(context, ${expression})" if $$self{codeGenerator}->IsNonPointerType($returnIDLType);
    483481    return "JSValueMakeStringOrNull(context, ${expression}.get())" if $$self{codeGenerator}->IsStringType($returnIDLType);
     
    489487    my ($self, $parameter) = @_;
    490488
    491     my $idlType = $parameter->type;
     489    my $idlType = $parameter->idlType;
    492490    my $name = $parameter->name;
    493491
     
    524522    my ($self, $interface, $functionOrValue, $arrayTerminator, $mapFunction, $functionsOrAttributes) = @_;
    525523
    526     my $className = _className($interface->name);
     524    my $className = _className($interface->type);
    527525    my $uppercaseFunctionOrValue = $$self{codeGenerator}->WK_ucfirst($functionOrValue);
    528526
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm

    r206851 r208023  
    2929package CodeGeneratorTestRunner;
    3030
     31use Carp qw<longmess>;
     32use Data::Dumper;
     33
     34sub assert
     35{
     36    my $message = shift;
     37   
     38    my $mess = longmess();
     39    print Dumper($mess);
     40
     41    die $message;
     42}
     43
    3144sub new
    3245{
     
    5871{
    5972    my ($idlType) = @_;
     73
     74    assert("Not a type") if ref($idlType) ne "domType";
    6075
    6176    return "JS" . _implementationClassName($idlType);
     
    143158    my @contents = ();
    144159
    145     my $idlType = $interface->name;
     160    my $idlType = $interface->type;
    146161    my $className = _className($idlType);
    147162    my $implementationClassName = _implementationClassName($idlType);
     
    210225    my @contents = ();
    211226
    212     my $idlType = $interface->name;
     227    my $idlType = $interface->type;
    213228    my $className = _className($idlType);
    214229    my $implementationClassName = _implementationClassName($idlType);
     
    245260    if (!jsClass) {
    246261        JSClassDefinition definition = kJSClassDefinitionEmpty;
    247         definition.className = "${idlType}";
     262        definition.className = "@{[$idlType->name]}";
    248263        definition.parentClass = @{[$self->_parentClassRefGetterExpression($interface)]};
    249264        definition.staticValues = staticValues();
     
    285300                my @specifiedParameters = @{$function->parameters};
    286301
    287                 $self->_includeHeaders(\%contentsIncludes, $function->signature->type, $function->signature);
     302                $self->_includeHeaders(\%contentsIncludes, $function->signature->idlType, $function->signature);
    288303
    289304                if ($function->signature->extendedAttributes->{"PassContext"}) {
     
    304319            }
    305320           
    306             push(@contents, "    ${functionCall};\n\n") if $function->signature->type eq "void";
     321            push(@contents, "    ${functionCall};\n\n") if $function->signature->idlType->name eq "void";
    307322            push(@contents, "    return " . $self->_returnExpression($function->signature, $functionCall) . ";\n}\n");
    308323        }
     
    312327        push(@contents, "\n// Attributes\n");
    313328        foreach my $attribute (@attributes) {
    314             $self->_includeHeaders(\%contentsIncludes, $attribute->signature->type, $attribute->signature);
     329            $self->_includeHeaders(\%contentsIncludes, $attribute->signature->idlType, $attribute->signature);
    315330
    316331            my $getterName = $self->_getterName($attribute);
     
    369384    my ($self, $attribute) = @_;
    370385
    371     my $signature = $attribute->signature;
    372     my $name = $signature->name;
    373 
    374     return $name;
     386    return $attribute->signature->name;
    375387}
    376388
     
    380392
    381393    return unless defined $idlType;
    382     return if $idlType eq "boolean";
    383     return if $idlType eq "object";
     394    return if $idlType->name eq "boolean";
     395    return if $idlType->name eq "object";
    384396    return if $$self{codeGenerator}->IsNonPointerType($idlType);
    385397    return if $$self{codeGenerator}->IsStringType($idlType);
     
    393405    my ($idlType) = @_;
    394406
    395     return $idlType;
     407    return $idlType->name;
    396408}
    397409
     
    415427{
    416428    my ($interface) = @_;
    417     return $interface->parent;
     429    return $interface->parentType;
    418430}
    419431
     
    424436    return undef unless defined $idlType;
    425437
    426     return "bool" if $idlType eq "boolean";
    427     return "JSValueRef" if $idlType eq "object";
     438    return "bool" if $idlType->name eq "boolean";
     439    return "JSValueRef" if $idlType->name eq "object";
    428440    return "JSRetainPtr<JSStringRef>" if $$self{codeGenerator}->IsStringType($idlType);
    429441    return "double" if $$self{codeGenerator}->IsNonPointerType($idlType);
     
    435447    my ($self, $signature, $argumentName) = @_;
    436448
    437     my $idlType = $signature->type;
    438 
    439     return "JSValueToBoolean(context, $argumentName)" if $idlType eq "boolean";
    440     return "$argumentName" if $idlType eq "object";
     449    my $idlType = $signature->idlType;
     450
     451    return "JSValueToBoolean(context, $argumentName)" if $idlType->name eq "boolean";
     452    return "$argumentName" if $idlType->name eq "object";
    441453    return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($idlType);
    442454    return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsNonPointerType($idlType);
     
    448460    my ($self, $signature, $variableName, $argumentName, $condition) = @_;
    449461
    450     my $platformType = $self->_platformType($signature->type, $signature);
     462    my $platformType = $self->_platformType($signature->idlType, $signature);
    451463    my $constructor = $self->_platformTypeConstructor($signature, $argumentName);
    452464
     
    476488    my ($self, $signature, $expression) = @_;
    477489
    478     my $returnIDLType = $signature->type;
    479 
    480     return "JSValueMakeUndefined(context)" if $returnIDLType eq "void";
    481     return "JSValueMakeBoolean(context, ${expression})" if $returnIDLType eq "boolean";
    482     return "${expression}" if $returnIDLType eq "object";
     490    my $returnIDLType = $signature->idlType;
     491
     492    return "JSValueMakeUndefined(context)" if $returnIDLType->name eq "void";
     493    return "JSValueMakeBoolean(context, ${expression})" if $returnIDLType->name eq "boolean";
     494    return "${expression}" if $returnIDLType->name eq "object";
    483495    return "JSValueMakeNumber(context, ${expression})" if $$self{codeGenerator}->IsNonPointerType($returnIDLType);
    484496    return "JSValueMakeStringOrNull(context, ${expression}.get())" if $$self{codeGenerator}->IsStringType($returnIDLType);
     
    490502    my ($self, $parameter) = @_;
    491503
    492     my $idlType = $parameter->type;
     504    my $idlType = $parameter->idlType;
    493505    my $name = $parameter->name;
    494506
     
    525537    my ($self, $interface, $functionOrValue, $arrayTerminator, $mapFunction, $functionsOrAttributes) = @_;
    526538
    527     my $className = _className($interface->name);
     539    my $className = _className($interface->type);
    528540    my $uppercaseFunctionOrValue = $$self{codeGenerator}->WK_ucfirst($functionOrValue);
    529541
Note: See TracChangeset for help on using the changeset viewer.