Changeset 208023 in webkit
- Timestamp:
- Oct 27, 2016 7:03:05 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r208022 r208023 1 2016-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 1 54 2016-10-27 Myles C. Maxfield <mmaxfield@apple.com> 2 55 -
trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm
r207937 r208023 274 274 my $currentInterface = shift; 275 275 276 for (@{$currentInterface->parents}) {277 my $interfaceName = $ _;276 if ($currentInterface->parentType) { 277 my $interfaceName = $currentInterface->parentType->name; 278 278 my $parentInterface = $object->ParseInterface($outerInterface, $interfaceName); 279 279 … … 327 327 } 328 328 329 sub GetAttributeFromInterface() 330 { 331 my $object = shift; 332 my $outerInterface = shift; 333 my $interfaceName = shift; 334 my $attributeName = shift; 329 sub GetAttributeFromInterface 330 { 331 my ($object, $outerInterface, $interfaceName, $attributeName) = @_; 335 332 336 333 my $interface = $object->ParseInterface($outerInterface, $interfaceName); … … 378 375 sub SkipIncludeHeader 379 376 { 380 my $object = shift; 381 my $type = shift; 377 my ($object, $typeName) = @_; 382 378 383 379 # FIXME: This is a lot like !IsRefPtrType. Maybe they could share code? 384 380 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"; 393 390 394 391 return 0; … … 399 396 my ($object, $type) = @_; 400 397 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}; 403 402 return 0; 404 403 } … … 408 407 my ($object, $type) = @_; 409 408 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); 411 412 return 1 if $object->IsEnumType($type); 412 413 return 0; … … 417 418 my ($object, $type) = @_; 418 419 419 return 1 if $integerTypeHash{$type}; 420 assert("Not a type") if ref($type) ne "domType"; 421 422 return 1 if $integerTypeHash{$type->name}; 420 423 return 0; 421 424 } … … 425 428 my ($object, $type) = @_; 426 429 427 return 1 if $floatingPointTypeHash{$type}; 430 assert("Not a type") if ref($type) ne "domType"; 431 432 return 1 if $floatingPointTypeHash{$type->name}; 428 433 return 0; 429 434 } … … 433 438 my ($object, $type) = @_; 434 439 435 return 1 if $primitiveTypeHash{$type}; 440 assert("Not a type") if ref($type) ne "domType"; 441 442 return 1 if $primitiveTypeHash{$type->name}; 436 443 return 1 if $object->IsNumericType($type); 437 444 return 0; … … 443 450 my ($object, $type) = @_; 444 451 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"; 447 456 return 0; 448 457 } … … 452 461 my ($object, $type) = @_; 453 462 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 468 sub GetEnumByType 469 { 470 my ($object, $type) = @_; 471 472 assert("Not a type") if ref($type) ne "domType"; 473 474 my $name = $type->name; 475 461 476 die "GetEnumByName() was called with an undefined enumeration name" unless defined($name); 462 477 … … 495 510 my ($object, $type) = @_; 496 511 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}); 508 515 } 509 516 … … 512 519 my ($object, $type) = @_; 513 520 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}; 515 524 return 0; 516 525 } … … 520 529 my ($object, $type) = @_; 521 530 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 536 sub 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); 529 545 530 546 for my $dictionary (@{$useDocument->dictionaries}) { … … 561 577 my ($object, $type) = @_; 562 578 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)); 564 582 } 565 583 … … 569 587 my ($object, $type) = @_; 570 588 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}); 572 592 } 573 593 … … 576 596 my ($object, $type) = @_; 577 597 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}; 579 601 return 0; 580 602 } … … 584 606 my ($object, $type) = @_; 585 607 586 return $dictionaryTypeImplementationNameOverrides{$type}; 608 assert("Not a type") if ref($type) ne "domType"; 609 610 return $dictionaryTypeImplementationNameOverrides{$type->name}; 587 611 } 588 612 … … 591 615 my ($object, $type) = @_; 592 616 593 return 1 if $nonPointerTypeHash{$type}; 617 assert("Not a type") if ref($type) ne "domType"; 618 619 return 1 if $nonPointerTypeHash{$type->name}; 594 620 return 1 if $object->IsPrimitiveType($type); 595 621 return 0; 596 622 } 597 623 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}; 624 sub 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 634 sub 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}; 613 641 return 0; 614 642 } … … 616 644 sub IsTypedArrayType 617 645 { 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}; 622 651 return 0; 623 652 } … … 625 654 sub IsRefPtrType 626 655 { 627 my $object = shift; 628 my $type = shift; 656 my ($object, $type) = @_; 657 658 assert("Not a type") if ref($type) ne "domType"; 629 659 630 660 return 0 if $object->IsPrimitiveType($type); … … 632 662 return 0 if $object->IsEnumType($type); 633 663 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"; 636 666 637 667 return 1; 638 668 } 639 669 640 sub GetSVGTypeNeedingTearOff 641 { 642 my $object = shift; 643 my $type = shift; 644 645 return $svgTypeNeedingTearOff{$type} if exists $svgTypeNeedingTearOff{$type}; 670 sub 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}; 646 677 return undef; 647 678 } 648 679 649 sub GetSVGWrappedTypeNeedingTearOff 650 { 651 my $object = shift; 652 my $type = shift; 653 654 my $svgTypeNeedingTearOff = $object->GetSVGTypeNeedingTearOff($type); 680 sub GetSVGWrappedTypeNeedingTearOffForType 681 { 682 my ($object, $type) = @_; 683 684 assert("Not a type") if ref($type) ne "domType"; 685 686 my $svgTypeNeedingTearOff = $object->GetSVGTypeNeedingTearOffForType($type); 655 687 return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff; 656 688 … … 669 701 } 670 702 703 sub IsSVGAnimatedTypeName 704 { 705 my ($object, $typeName) = @_; 706 707 return $typeName =~ /^SVGAnimated/; 708 } 709 671 710 sub IsSVGAnimatedType 672 711 { 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 719 sub IsConstructorType 720 { 721 my ($object, $type) = @_; 722 723 assert("Not a type") if ref($type) ne "domType"; 724 725 return $type->name =~ /Constructor$/; 677 726 } 678 727 679 728 sub IsSequenceType 680 729 { 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"; 685 735 } 686 736 687 737 sub GetSequenceInnerType 688 738 { 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]; 694 744 } 695 745 696 746 sub IsFrozenArrayType 697 747 { 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"; 702 754 } 703 755 704 756 sub GetFrozenArrayInnerType 705 757 { 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]; 711 763 } 712 764 713 765 sub IsSequenceOrFrozenArrayType 714 766 { 715 my $object = shift; 716 my $type = shift; 767 my ($object, $type) = @_; 768 769 assert("Not a type") if ref($type) ne "domType"; 717 770 718 771 return $object->IsSequenceType($type) || $object->IsFrozenArrayType($type); … … 721 774 sub GetSequenceOrFrozenArrayInnerType 722 775 { 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]; 729 781 } 730 782 … … 735 787 { 736 788 my ($object, $param) = @_; 789 737 790 my $ret = ucfirst($param); 738 791 $ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/; … … 747 800 { 748 801 my ($object, $param) = @_; 802 749 803 my $ret = lcfirst($param); 750 804 $ret =~ s/dOM/dom/ if $ret =~ /^dOM/; … … 765 819 } 766 820 767 sub slurp { 821 sub slurp 822 { 768 823 my $file = shift; 769 824 … … 778 833 { 779 834 my $string = shift; 835 780 836 $string =~ s/^\s+|\s+$//g; 781 837 return $string; … … 786 842 { 787 843 my ($object, $interfaceName, $attributeName) = @_; 844 788 845 return "SVGNames" if $interfaceName =~ /^SVG/ && !$svgAttributesInHTMLHash{$attributeName}; 789 846 return "HTMLNames"; … … 821 878 $attributeName = $attribute->signature->extendedAttributes->{"ImplementedAs"}; 822 879 } 823 my $attributeType = $attribute->signature-> type;880 my $attributeType = $attribute->signature->idlType; 824 881 825 882 # SVG animated types need to use a special attribute name. … … 855 912 } 856 913 857 my $attributeType = $attribute->signature-> type;914 my $attributeType = $attribute->signature->idlType; 858 915 859 916 my $functionName; 860 917 if ($attribute->signature->extendedAttributes->{"URL"}) { 861 918 $functionName = "getURLAttribute"; 862 } elsif ($attributeType eq "boolean") {919 } elsif ($attributeType->name eq "boolean") { 863 920 $functionName = "hasAttributeWithoutSynchronization"; 864 } elsif ($attributeType eq "long") {921 } elsif ($attributeType->name eq "long") { 865 922 $functionName = "getIntegralAttribute"; 866 } elsif ($attributeType eq "unsigned long") {923 } elsif ($attributeType->name eq "unsigned long") { 867 924 $functionName = "getUnsignedIntegralAttribute"; 868 925 } else { … … 893 950 } 894 951 895 my $attributeType = $attribute->signature-> type;952 my $attributeType = $attribute->signature->idlType; 896 953 897 954 my $functionName; 898 if ($attributeType eq "boolean") {955 if ($attributeType->name eq "boolean") { 899 956 $functionName = "setBooleanAttribute"; 900 } elsif ($attributeType eq "long") {957 } elsif ($attributeType->name eq "long") { 901 958 $functionName = "setIntegralAttribute"; 902 } elsif ($attributeType eq "unsigned long") {959 } elsif ($attributeType->name eq "unsigned long") { 903 960 $functionName = "setUnsignedIntegralAttribute"; 904 961 } elsif ($generator->IsSVGAnimatedType($attributeType)) { … … 913 970 sub IsWrapperType 914 971 { 915 my $object = shift; 916 my $type = shift; 972 my ($object, $type) = @_; 973 974 assert("Not a type") if ref($type) ne "domType"; 917 975 918 976 return 0 if !$object->IsRefPtrType($type); 919 977 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}; 923 981 924 982 return 1; 925 983 } 926 984 927 sub getInterfaceExtendedAttributesFromName985 sub GetInterfaceExtendedAttributesFromName 928 986 { 929 987 # FIXME: It's bad to have a function like this that opens another IDL file to answer a question. 930 988 # Overusing this kind of function can make things really slow. Lets avoid these if we can. 931 989 932 my $object = shift; 933 my $interfaceName = shift; 990 my ($object, $interfaceName) = @_; 934 991 935 992 my $idlFile = $object->IDLFileForInterface($interfaceName) or assert("Could NOT find IDL file for interface \"$interfaceName\"!\n"); … … 960 1017 sub ComputeIsCallbackInterface 961 1018 { 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); 975 1034 } 976 1035 … … 985 1044 my ($object, $type) = @_; 986 1045 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; 990 1051 return $result; 991 1052 } … … 996 1057 sub ComputeIsFunctionOnlyCallbackInterface 997 1058 { 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; 1024 1087 } 1025 1088 … … 1034 1097 my ($object, $type) = @_; 1035 1098 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; 1039 1104 return $result; 1040 1105 } … … 1042 1107 sub GenerateConditionalString 1043 1108 { 1044 my $generator = shift; 1045 my $node = shift; 1109 my ($generator, $node) = @_; 1046 1110 1047 1111 my $conditional = $node->extendedAttributes->{"Conditional"}; … … 1055 1119 sub GenerateConditionalStringFromAttributeValue 1056 1120 { 1057 my $generator = shift; 1058 my $conditional = shift; 1121 my ($generator, $conditional) = @_; 1059 1122 1060 1123 my %disjunction; … … 1115 1178 sub GetVisibleInterfaceName 1116 1179 { 1117 my $object = shift;1118 my $interface = shift; 1180 my ($object, $interface) = @_; 1181 1119 1182 my $interfaceName = $interface->extendedAttributes->{"InterfaceName"}; 1120 1183 return $interfaceName ? $interfaceName : $interface->name; … … 1123 1186 sub InheritsInterface 1124 1187 { 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 1128 1192 my $found = 0; 1129 1130 return 1 if $interfaceName eq $interface->name;1131 1193 $object->ForAllParents($interface, sub { 1132 1194 my $currentInterface = shift; … … 1142 1204 sub InheritsExtendedAttribute 1143 1205 { 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 1147 1210 my $found = 0; 1148 1149 return 1 if $interface->extendedAttributes->{$extendedAttribute};1150 1211 $object->ForAllParents($interface, sub { 1151 1212 my $currentInterface = shift; … … 1161 1222 sub ShouldPassWrapperByReference 1162 1223 { 1163 my $object = shift; 1164 my $parameter = shift; 1165 my $interface = shift; 1224 my ($object, $parameter, $interface) = @_; 1166 1225 1167 1226 return 0 if $parameter->isVariadic; 1168 1227 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); 1171 1230 1172 1231 return 1; -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207937 r208023 137 137 my ($object, $enumeration) = @_; 138 138 139 my $className = GetEnumerationClassName($enumeration-> name);139 my $className = GetEnumerationClassName($enumeration->type); 140 140 $object->GenerateEnumerationHeader($enumeration, $className); 141 141 $object->GenerateEnumerationImplementation($enumeration, $className); … … 146 146 my ($object, $dictionary, $enumerations) = @_; 147 147 148 my $className = GetDictionaryClassName($dictionary-> name);148 my $className = GetDictionaryClassName($dictionary->type); 149 149 $object->GenerateDictionaryHeader($dictionary, $className, $enumerations); 150 150 $object->GenerateDictionaryImplementation($dictionary, $className, $enumerations); … … 180 180 $stringifier->signature->extendedAttributes($extendedAttributeList); 181 181 $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); 183 183 184 184 # FIXME: This should use IDLParser's cloneType. 185 185 my $type = domType->new(); 186 $type->name($attribute->signature-> type);186 $type->name($attribute->signature->idlType->name); 187 187 188 188 $stringifier->signature->idlType($type); 189 $stringifier->signature->type($type->name);190 189 191 190 push(@{$interface->functions}, $stringifier); … … 211 210 return $interface->extendedAttributes->{JSLegacyParent} if $interface->extendedAttributes->{JSLegacyParent}; 212 211 return "JSDOMObject" unless NeedsImplementationClass($interface); 213 return "JSDOMWrapper<" . GetImplClassName($interface ->name) . ">" unless $interface->parent;212 return "JSDOMWrapper<" . GetImplClassName($interface) . ">" unless $interface->parent; 214 213 return "JS" . $interface->parent; 215 214 } … … 227 226 228 227 return $callbackInterface->extendedAttributes->{IsWeakCallback} ? "JSCallbackDataWeak" : "JSCallbackDataStrong"; 229 }230 231 sub AddIncludesForTypeInImpl232 {233 my $type = shift;234 my $isCallback = @_ ? shift : 0;235 236 AddIncludesForType($type, $isCallback, \%implIncludes);237 }238 239 sub AddIncludesForTypeInHeader240 {241 my $type = shift;242 my $isCallback = @_ ? shift : 0;243 244 AddIncludesForType($type, $isCallback, \%headerIncludes);245 228 } 246 229 … … 253 236 } 254 237 255 sub AddIncludesForType 256 { 257 my $type = shift; 258 my $isCallback = shift; 259 my $includesRef = shift; 260 261 return if $codeGenerator->SkipIncludeHeader($type); 238 sub AddIncludesForImplementationTypeInImpl 239 { 240 my $implementationType = shift; 262 241 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 245 sub AddIncludesForImplementationTypeInHeader 246 { 247 my $implementationType = shift; 248 249 AddIncludesForImplementationType($implementationType, \%headerIncludes); 250 } 251 252 sub AddIncludesForImplementationType 253 { 254 my ($implementationType, $includesRef) = @_; 255 256 return if $codeGenerator->SkipIncludeHeader($implementationType); 257 258 $includesRef->{"${implementationType}.h"} = 1; 277 259 } 278 260 … … 293 275 } 294 276 295 if ($codeGenerator->IsSequenceOrFrozenArrayType($idlType->name)) { 277 if ($codeGenerator->IsSequenceOrFrozenArrayType($idlType)) { 278 AddToImplIncludes("<runtime/JSArray.h>", $conditional); 296 279 AddToImplIncludesForIDLType(@{$idlType->subtypes}[0], $conditional); 297 280 return; 298 281 } 299 282 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)) { 306 284 AddToImplIncludes("JS" . $idlType->name . ".h", $conditional); 307 285 return; … … 332 310 sub AddClassForwardIfNeeded 333 311 { 334 my $ interfaceName = shift;312 my $type = shift; 335 313 336 314 # 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"); 343 320 } 344 321 … … 400 377 # If the item function returns a string then we let the TreatReturnedNullStringAs handle the cases 401 378 # 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") { 403 382 push(@getOwnPropertySlotImpl, " if (optionalIndex) {\n"); 404 383 } else { … … 557 536 return $codeGenerator->WK_lcfirst($className) . "Constructor" . $codeGenerator->WK_ucfirst($attribute->signature->name) if $attribute->isStatic; 558 537 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" : ""); 560 539 } 561 540 … … 566 545 return "set" . $codeGenerator->WK_ucfirst($className) . "Constructor" . $codeGenerator->WK_ucfirst($attribute->signature->name) if $attribute->isStatic; 567 546 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" : ""); 569 548 } 570 549 … … 593 572 my $specialExists = grep { $_ eq $special } @$specials; 594 573 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) { 596 575 return $function; 597 576 } … … 636 615 637 616 return 1 if InterfaceRequiresAttributesOnInstance($interface); 638 return 1 if $ attribute->signature->type =~ /Constructor$/;617 return 1 if $codeGenerator->IsConstructorType($attribute->signature->idlType); 639 618 640 619 # [Unforgeable] attributes should be on the instance. … … 678 657 679 658 # 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$/; 681 660 push(@specials, "DontEnum") if ($attribute->signature->extendedAttributes->{NotEnumerable} || $is_global_constructor); 682 661 push(@specials, "ReadOnly") if IsReadonly($attribute); … … 799 778 sub GetImplClassName 800 779 { 801 my $ name = shift;802 803 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($ name);780 my $interface = shift; 781 782 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interface); 804 783 return $svgNativeType if $svgNativeType; 805 784 806 return $ name;785 return $interface->name; 807 786 } 808 787 … … 836 815 my ($interface, $name) = @_; 837 816 838 my $class = GetImplClassName($interface ->name);817 my $class = GetImplClassName($interface); 839 818 my $member = $codeGenerator->WK_ucfirst($name); 840 819 … … 856 835 sub GetEnumerationClassName 857 836 { 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); 865 848 return $name unless defined($interface); 866 849 … … 1000 983 my $result = ""; 1001 984 foreach my $enumeration (@$enumerations) { 1002 my $name = $enumeration->name; 1003 1004 my $className = GetEnumerationClassName($name, $interface); 985 my $className = GetEnumerationClassName($enumeration->type, $interface); 1005 986 my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration); 1006 987 $result .= GenerateEnumerationImplementationContent($enumeration, $className, $interface, $conditionalString); … … 1037 1018 my $result = ""; 1038 1019 foreach my $enumeration (@$enumerations) { 1039 my $className = GetEnumerationClassName($enumeration-> name, $interface);1020 my $className = GetEnumerationClassName($enumeration->type, $interface); 1040 1021 my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration); 1041 1022 $result .= GenerateEnumerationHeaderContent($enumeration, $className, $conditionalString); … … 1046 1027 sub GetDictionaryClassName 1047 1028 { 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); 1055 1037 return $name unless defined($interface); 1056 1038 return GetNestedClassName($interface, $name); … … 1063 1045 my $defaultValue = $signature->default; 1064 1046 1065 if ($codeGenerator->IsEnumType($signature-> type)) {1047 if ($codeGenerator->IsEnumType($signature->idlType)) { 1066 1048 # FIXME: Would be nice to report an error if the value does not have quote marks around it. 1067 1049 # 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); 1069 1051 my $enumerationValueName = GetEnumerationValueName(substr($defaultValue, 1, -1)); 1070 1052 return $className . "::" . $enumerationValueName; … … 1077 1059 return "convert<${IDLType}>(state, jsNull());"; 1078 1060 } 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); 1082 1064 return "Nullopt"; 1083 1065 } … … 1091 1073 1092 1074 return $defaultValue; 1093 }1094 1095 sub ShouldAllowNonFiniteForFloatingPointType1096 {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 GenerateConversionRuleWithLeadingComma1104 {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 "";1112 1075 } 1113 1076 … … 1134 1097 foreach my $dictionary (@$allDictionaries) { 1135 1098 $headerIncludes{$interface->name . ".h"} = 1; 1136 my $className = GetDictionaryClassName($dictionary-> name, $interface);1099 my $className = GetDictionaryClassName($dictionary->type, $interface); 1137 1100 my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary); 1138 1101 $result .= GenerateDictionaryHeaderContent($dictionary, $className, $conditionalString); … … 1179 1142 my @dictionaries; 1180 1143 push(@dictionaries, $dictionary); 1181 my $parent Name = $dictionary->parent;1182 while (defined($parent Name)) {1183 my $parentDictionary = $codeGenerator->GetDictionaryBy Name($parentName);1184 assert("Unable to find definition for dictionary named '" . $parent Name . "'!") 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); 1185 1148 unshift(@dictionaries, $parentDictionary); 1186 $parent Name = $parentDictionary->parent;1149 $parentType = $parentDictionary->parentType; 1187 1150 } 1188 1151 … … 1245 1208 my $result = ""; 1246 1209 foreach my $dictionary (@$allDictionaries) { 1247 my $className = GetDictionaryClassName($dictionary-> name, $interface);1210 my $className = GetDictionaryClassName($dictionary->type, $interface); 1248 1211 my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary); 1249 1212 $result .= GenerateDictionaryImplementationContent($dictionary, $className, $interface, $conditionalString); … … 1318 1281 $headerIncludes{"SVGElement.h"} = 1 if $className =~ /^JSSVG/; 1319 1282 1320 my $implType = GetImplClassName($interface Name);1321 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interface Name);1283 my $implType = GetImplClassName($interface); 1284 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interface); 1322 1285 my $svgPropertyOrListPropertyType; 1323 1286 $svgPropertyOrListPropertyType = $svgPropertyType if $svgPropertyType; … … 1330 1293 push(@headerContent, "\nnamespace WebCore {\n\n"); 1331 1294 1332 if ($codeGenerator->IsSVGAnimatedType($interface Name)) {1295 if ($codeGenerator->IsSVGAnimatedType($interface->type)) { 1333 1296 $headerIncludes{"$interfaceName.h"} = 1; 1334 1297 } else { 1335 1298 # Implementation class forward declaration 1336 1299 if (IsDOMGlobalObject($interface)) { 1337 AddClassForwardIfNeeded($interface Name) 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"; 1342 1305 1343 1306 my $exportMacro = GetExportMacroForJSClass($interface); … … 1368 1331 push(@headerContent, " }\n\n"); 1369 1332 } elsif ($interface->extendedAttributes->{MasqueradesAsUndefined}) { 1370 AddIncludesFor TypeInHeader($implType) unless $svgPropertyOrListPropertyType;1333 AddIncludesForImplementationTypeInHeader($implType) unless $svgPropertyOrListPropertyType; 1371 1334 push(@headerContent, " static $className* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<$implType>&& impl)\n"); 1372 1335 push(@headerContent, " {\n"); … … 1384 1347 push(@headerContent, " }\n\n"); 1385 1348 } else { 1386 AddIncludesFor TypeInHeader($implType) unless $svgPropertyOrListPropertyType;1349 AddIncludesForImplementationTypeInHeader($implType) unless $svgPropertyOrListPropertyType; 1387 1350 push(@headerContent, " static $className* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<$implType>&& impl)\n"); 1388 1351 push(@headerContent, " {\n"); … … 1405 1368 # JSValue to implementation type 1406 1369 if (ShouldGenerateToWrapped($hasParent, $interface)) { 1407 my $nativeType = GetNativeType($interface, $i mplType);1370 my $nativeType = GetNativeType($interface, $interface->type); 1408 1371 if ($interface->name eq "XPathNSResolver") { 1409 1372 push(@headerContent, " static $nativeType toWrapped(JSC::ExecState&, JSC::JSValue);\n"); … … 1819 1782 }, 0); 1820 1783 for my $dictionary (@$dictionaries) { 1821 my $parent Name = $dictionary->parent;1822 while (defined($parent Name)) {1823 push(@ancestors, $parent Name) if $codeGenerator->IsExternalDictionaryType($parentName);1824 my $parentDictionary = $codeGenerator->GetDictionaryBy Name($parentName);1825 assert("Unable to find definition for dictionary named '" . $parent Name . "'!") unless defined($parentDictionary);1826 $parent Name = $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; 1827 1790 } 1828 1791 } … … 2033 1996 my $isDictionary = sub { 2034 1997 my $type = shift; 2035 return $type eq "Dictionary" || $codeGenerator->IsDictionaryType($type);1998 return $type->name eq "Dictionary" || $codeGenerator->IsDictionaryType($type); 2036 1999 }; 2037 2000 my $isCallbackFunctionOrDictionary = sub { … … 2061 2024 return 0 if $idlTypeA->name eq $idlTypeB->name; 2062 2025 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); 2069 2032 # FIXME: return 0 if $idlTypeA and $idlTypeB are both exception types. 2070 2033 return 1; … … 2163 2126 my $isDictionaryParameter = sub { 2164 2127 my ($idlType, $optionality) = @_; 2165 return $idlType->name eq "Dictionary" || $codeGenerator->IsDictionaryType($idlType ->name);2128 return $idlType->name eq "Dictionary" || $codeGenerator->IsDictionaryType($idlType); 2166 2129 }; 2167 2130 my $isNullableOrDictionaryParameterOrUnionContainingOne = sub { … … 2192 2155 my $isObjectOrCallbackFunctionParameter = sub { 2193 2156 my ($idlType, $optionality) = @_; 2194 return $idlType->name eq "object" || $codeGenerator->IsFunctionOnlyCallbackInterface($idlType ->name);2157 return $idlType->name eq "object" || $codeGenerator->IsFunctionOnlyCallbackInterface($idlType); 2195 2158 }; 2196 2159 my $isSequenceOrFrozenArrayParameter = sub { 2197 2160 my ($idlType, $optionality) = @_; 2198 return $codeGenerator->IsSequenceOrFrozenArrayType($idlType ->name);2161 return $codeGenerator->IsSequenceOrFrozenArrayType($idlType); 2199 2162 }; 2200 2163 my $isDictionaryOrObjectOrCallbackInterfaceParameter = sub { … … 2202 2165 return 1 if &$isDictionaryParameter($idlType, $optionality); 2203 2166 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); 2205 2168 return 0; 2206 2169 }; … … 2211 2174 my $isNumericParameter = sub { 2212 2175 my ($idlType, $optionality) = @_; 2213 return $codeGenerator->IsNumericType($idlType ->name);2176 return $codeGenerator->IsNumericType($idlType); 2214 2177 }; 2215 2178 my $isStringOrEnumParameter = sub { 2216 2179 my ($idlType, $optionality) = @_; 2217 return $codeGenerator->IsStringOrEnumType($idlType ->name);2180 return $codeGenerator->IsStringOrEnumType($idlType); 2218 2181 }; 2219 2182 my $isAnyParameter = sub { … … 2261 2224 my @idlSubtypes = $idlType->isUnion ? GetFlattenedMemberTypes($idlType) : ( $idlType ); 2262 2225 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") { 2266 2228 AddToImplIncludes("JSDOMWindowShell.h"); 2267 2229 &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && (asObject(distinguishingArg)->inherits(JSDOMWindowShell::info()) || asObject(distinguishingArg)->inherits(JSDOMWindow::info()))"); 2268 2230 } else { 2269 &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JS ${type}::info())");2231 &$generateOverloadCallIfNecessary($overload, "distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JS" . $idlSubtype->name . "::info())"); 2270 2232 } 2271 2233 } … … 2368 2330 { 2369 2331 my $interface = shift; 2332 2370 2333 my $interfaceName = $interface->name; 2371 $interfaceName = $codeGenerator->GetSVGTypeNeedingTearOff ($interfaceName) if $codeGenerator->IsSVGTypeNeedingTearOff($interfaceName);2334 $interfaceName = $codeGenerator->GetSVGTypeNeedingTearOffForType($interface->type) if $codeGenerator->IsSVGTypeNeedingTearOffForType($interface->type); 2372 2335 return $interfaceName; 2373 2336 } … … 2532 2495 { 2533 2496 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"; 2535 2500 return "toJS(state, thisObject->globalObject(), thisObject->wrapped().item(index))"; 2536 2501 } … … 2616 2581 $implIncludes{"<runtime/PropertyNameArray.h>"} = 1 if $indexedGetterFunction; 2617 2582 2618 my $implType = GetImplClassName($interface Name);2583 my $implType = GetImplClassName($interface); 2619 2584 2620 2585 AddJSBuiltinIncludesIfNeeded($interface); … … 2923 2888 push(@implContent, ", CREATE_METHOD_TABLE($className) };\n\n"); 2924 2889 2925 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interface Name);2890 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($interface); 2926 2891 my $svgPropertyOrListPropertyType; 2927 2892 $svgPropertyOrListPropertyType = $svgPropertyType if $svgPropertyType; … … 2930 2895 # Constructor 2931 2896 if ($interfaceName eq "DOMWindow") { 2932 AddIncludesFor TypeInImpl("JSDOMWindowShell");2897 AddIncludesForImplementationTypeInImpl("JSDOMWindowShell"); 2933 2898 push(@implContent, "${className}::$className(VM& vm, Structure* structure, Ref<$implType>&& impl, JSDOMWindowShell* shell)\n"); 2934 2899 push(@implContent, " : $parentClassName(vm, structure, WTFMove(impl), shell)\n"); … … 2936 2901 push(@implContent, "}\n\n"); 2937 2902 } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) { 2938 AddIncludesFor TypeInImpl($interfaceName);2903 AddIncludesForImplementationTypeInImpl($interfaceName); 2939 2904 push(@implContent, "${className}::$className(VM& vm, Structure* structure, Ref<$implType>&& impl)\n"); 2940 2905 push(@implContent, " : $parentClassName(vm, structure, WTFMove(impl))\n"); … … 3080 3045 3081 3046 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") { 3083 3049 push(@implContent, " if (LIKELY(index <= MAX_ARRAY_INDEX)) {\n"); 3084 3050 } else { … … 3159 3125 3160 3126 my $name = $attribute->signature->name; 3161 my $ type = $attribute->signature->type;3127 my $idlType = $attribute->signature->idlType; 3162 3128 my $getFunctionName = GetAttributeGetterName($interface, $className, $attribute); 3163 3129 my $implGetterFunctionName = $codeGenerator->WK_lcfirst($attribute->signature->extendedAttributes->{ImplementedAs} || $name); … … 3169 3135 push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; 3170 3136 3171 if (!$attribute->isStatic || $ attribute->signature->type =~ /Constructor$/) {3137 if (!$attribute->isStatic || $codeGenerator->IsConstructorType($idlType)) { 3172 3138 my $templateParameters = "${getFunctionName}Getter"; 3173 3139 if ($attribute->signature->extendedAttributes->{LenientThis}) { … … 3208 3174 3209 3175 # Global constructors can be disabled at runtime. 3210 if ($ attribute->signature->type =~ /Constructor$/) {3176 if ($codeGenerator->IsConstructorType($idlType)) { 3211 3177 if ($attribute->signature->extendedAttributes->{EnabledBySetting}) { 3212 3178 AddToImplIncludes("Frame.h"); … … 3243 3209 push(@implContent, " InputCursor& cursor = globalObject->inputCursor();\n"); 3244 3210 3245 my $nativeType = GetNativeType($interface, $ type);3246 my $memoizedType = GetNativeTypeForMemoization($interface, $ type);3211 my $nativeType = GetNativeType($interface, $idlType); 3212 my $memoizedType = GetNativeTypeForMemoization($interface, $idlType); 3247 3213 my $exceptionCode = $getterMayThrowLegacyException ? "ec" : "0"; 3248 3214 push(@implContent, " static NeverDestroyed<const AtomicString> bindingName(\"$interfaceName.$name\", AtomicString::ConstructFromLiteral);\n"); … … 3274 3240 push(@implContent, " auto& impl = thisObject.wrapped();\n"); 3275 3241 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") { 3277 3243 $implIncludes{"EventNames.h"} = 1; 3278 3244 my $getter = $attribute->signature->extendedAttributes->{WindowEventHandler} ? "windowEventHandlerAttribute" … … 3281 3247 my $eventName = EventHandlerAttributeEventName($attribute); 3282 3248 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; 3285 3251 $constructorType =~ s/Constructor$//; 3286 3252 # When Constructor attribute is used by DOMWindow.idl, it's correct to pass thisObject as the global object … … 3331 3297 my $jsType = NativeToJSValueUsingReferences($attribute->signature, 0, $interface, "${functionName}(" . join(", ", @arguments) . ")", "thisObject"); 3332 3298 push(@implContent, " auto& impl = thisObject.wrapped();\n") if !$attribute->isStatic; 3333 if ($codeGenerator->IsSVGAnimatedType($ type)) {3299 if ($codeGenerator->IsSVGAnimatedType($idlType)) { 3334 3300 push(@implContent, " auto obj = $jsType;\n"); 3335 3301 push(@implContent, " JSValue result = toJS(&state, thisObject.globalObject(), obj.get());\n"); … … 3479 3445 3480 3446 my $name = $attribute->signature->name; 3481 my $ type = $attribute->signature->type;3447 my $idlType = $attribute->signature->idlType; 3482 3448 my $putFunctionName = GetAttributeSetterName($interface, $className, $attribute); 3483 3449 my $implSetterFunctionName = $codeGenerator->WK_ucfirst($name); … … 3533 3499 push(@implContent, " thisObject.set$implSetterFunctionName(state, value);\n"); 3534 3500 push(@implContent, " return true;\n"); 3535 } elsif ($ type eq "EventHandler") {3501 } elsif ($idlType->name eq "EventHandler") { 3536 3502 $implIncludes{"JSEventListener.h"} = 1; 3537 3503 my $eventName = EventHandlerAttributeEventName($attribute); … … 3548 3514 } 3549 3515 push(@implContent, " return true;\n"); 3550 } elsif ($ type =~ /Constructor$/) {3551 my $constructorType = $ type;3516 } elsif ($codeGenerator->IsConstructorType($idlType)) { 3517 my $constructorType = $idlType->name; 3552 3518 $constructorType =~ s/Constructor$//; 3553 3519 # $constructorType ~= /Constructor$/ indicates that it is NamedConstructor. … … 3571 3537 if ($putForwards) { 3572 3538 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); 3574 3540 3575 3541 if ($forwardedAttribute->signature->extendedAttributes->{CEReactions}) { … … 3580 3546 } 3581 3547 3548 my $typeName = $idlType->name; 3582 3549 if ($attribute->signature->isNullable) { 3583 push(@implContent, " RefPtr<${type }> forwardedImpl = thisObject.wrapped().${implGetterFunctionName}();\n");3550 push(@implContent, " RefPtr<${typeName}> forwardedImpl = thisObject.wrapped().${implGetterFunctionName}();\n"); 3584 3551 push(@implContent, " if (!forwardedImpl)\n"); 3585 3552 push(@implContent, " return false;\n"); … … 3587 3554 } else { 3588 3555 # 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"); 3590 3557 push(@implContent, " auto& impl = forwardedImpl.get();\n"); 3591 3558 } 3592 3559 $attribute = $forwardedAttribute; 3593 $ type = $attribute->signature->type;3560 $idlType = $attribute->signature->idlType; 3594 3561 } else { 3595 3562 push(@implContent, " auto& impl = thisObject.wrapped();\n"); … … 3602 3569 3603 3570 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))) { 3605 3572 $implIncludes{"<runtime/Error.h>"} = 1; 3606 3573 push(@implContent, " " . GetNativeTypeFromSignature($interface, $attribute->signature) . " nativeValue = nullptr;\n"); … … 3609 3576 push(@implContent, " RETURN_IF_EXCEPTION(throwScope, false);\n") if $mayThrowException; 3610 3577 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"); 3612 3579 push(@implContent, " return false;\n"); 3613 3580 push(@implContent, " }\n"); … … 3618 3585 } 3619 3586 3620 if ($codeGenerator->IsEnumType($ type)) {3587 if ($codeGenerator->IsEnumType($idlType)) { 3621 3588 push (@implContent, " if (UNLIKELY(!nativeValue))\n"); 3622 3589 push (@implContent, " return false;\n"); … … 3625 3592 if ($shouldPassByReference) { 3626 3593 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"); 3628 3595 push(@implContent, " return false;\n"); 3629 3596 push(@implContent, " }\n"); … … 3661 3628 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute); 3662 3629 3663 if ($codeGenerator->IsTypedArrayType($ type) and not $type eq "ArrayBuffer") {3630 if ($codeGenerator->IsTypedArrayType($idlType) and not $idlType->name eq "ArrayBuffer") { 3664 3631 push(@arguments, "nativeValue.get()"); 3665 } elsif ($codeGenerator->IsEnumType($ type)) {3632 } elsif ($codeGenerator->IsEnumType($idlType)) { 3666 3633 push(@arguments, "nativeValue.value()"); 3667 3634 } else { … … 3752 3719 next if $isCustom && $isOverloaded && $function->{overloadIndex} > 1; 3753 3720 3754 Add IncludesForTypeInImpl($function->signature->type) unless $isCustom or IsReturningPromise($function);3721 AddToImplIncludesForIDLType($function->signature->idlType) unless $isCustom or IsReturningPromise($function); 3755 3722 3756 3723 my $functionName = GetFunctionName($interface, $className, $function); … … 3950 3917 3951 3918 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"; 3953 3921 if ($interfaceName =~ /^HTML\w*Collection$/ or $interfaceName eq "RadioNodeList") { 3954 3922 $implIncludes{"JSNode.h"} = 1; … … 4301 4269 sub WillConvertUndefinedToDefaultParameterValue 4302 4270 { 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}; 4307 4274 return 1 if defined $automaticallyGeneratedDefaultValue && $automaticallyGeneratedDefaultValue eq $defaultValue; 4308 4275 … … 4350 4317 my $argumentIndex = 0; 4351 4318 foreach my $parameter (@{$function->parameters}) { 4352 my $type = $parameter->type;4353 4319 my $idlType = $parameter->idlType; 4354 4320 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); 4356 4322 die "Optional parameters preceding variadic parameters are not supported" if ($parameter->isOptional && @{$function->parameters}[$numParameters - 1]->isVariadic); 4357 4323 4358 4324 if ($parameter->isOptional && !defined($parameter->default)) { 4359 4325 # 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); 4361 4327 4362 4328 # 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"; 4364 4330 4365 4331 # 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); 4367 4333 4368 4334 # As per Web IDL, passing undefined for a nullable parameter is treated as null. Therefore, use null as … … 4371 4337 4372 4338 # 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); 4374 4340 } 4375 4341 … … 4377 4343 my $value = $name; 4378 4344 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; 4381 4348 $implIncludes{"$callbackClassName.h"} = 1; 4382 4349 if ($parameter->isOptional) { 4383 push(@$outputArray, " RefPtr<$type > $name;\n");4350 push(@$outputArray, " RefPtr<$typeName> $name;\n"); 4384 4351 push(@$outputArray, " if (!state->argument($argumentIndex).isUndefinedOrNull()) {\n"); 4385 if ($codeGenerator->IsFunctionOnlyCallbackInterface($ type)) {4352 if ($codeGenerator->IsFunctionOnlyCallbackInterface($idlType)) { 4386 4353 push(@$outputArray, " if (!state->uncheckedArgument($argumentIndex).isFunction())\n"); 4387 4354 } else { … … 4398 4365 } else { 4399 4366 die "CallbackInterface does not support Variadic parameter" if $parameter->isVariadic; 4400 if ($codeGenerator->IsFunctionOnlyCallbackInterface($ type)) {4367 if ($codeGenerator->IsFunctionOnlyCallbackInterface($idlType)) { 4401 4368 push(@$outputArray, " if (UNLIKELY(!state->uncheckedArgument($argumentIndex).isFunction()))\n"); 4402 4369 } else { … … 4422 4389 $value = "WTFMove($name.arguments.value())"; 4423 4390 4424 } elsif ($codeGenerator->IsEnumType($ type)) {4425 my $className = GetEnumerationClassName($ type, $interface);4391 } elsif ($codeGenerator->IsEnumType($idlType)) { 4392 my $className = GetEnumerationClassName($idlType, $interface); 4426 4393 4427 4394 $implIncludes{"<runtime/Error.h>"} = 1; … … 4455 4422 } 4456 4423 4457 $implIncludes{"JS$className.h"} = 1 if $codeGenerator->IsExternalEnumType($ type);4424 $implIncludes{"JS$className.h"} = 1 if $codeGenerator->IsExternalEnumType($idlType); 4458 4425 push(@$outputArray, "$indent $defineOptionalValue = parseEnumeration<$className>(*state, ${name}Value);\n"); 4459 4426 push(@$outputArray, "$indent RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n"); … … 4467 4434 my $inner; 4468 4435 my $nativeType = GetNativeTypeFromSignature($interface, $parameter); 4469 my $isTearOff = $codeGenerator->IsSVGTypeNeedingTearOff ($type) && $interfaceName !~ /List$/;4436 my $isTearOff = $codeGenerator->IsSVGTypeNeedingTearOffForType($idlType) && $interfaceName !~ /List$/; 4470 4437 my $shouldPassByReference = $isTearOff || ShouldPassWrapperByReference($parameter, $interface); 4471 4438 … … 4473 4440 my $argumentLookupMethod = $parameter->isOptional ? "argument" : "uncheckedArgument"; 4474 4441 4475 if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($ type) || $codeGenerator->IsTypedArrayType($type))) {4442 if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($idlType) || $codeGenerator->IsTypedArrayType($idlType))) { 4476 4443 $implIncludes{"<runtime/Error.h>"} = 1; 4477 4444 my $checkedArgument = "state->$argumentLookupMethod($argumentIndex)"; … … 4483 4450 push(@$outputArray, " RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException; 4484 4451 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"); 4486 4453 push(@$outputArray, " }\n"); 4487 4454 $value = "WTFMove($name)"; 4488 4455 } else { 4489 if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($ type, $parameter->default)) {4456 if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($idlType, $parameter->default)) { 4490 4457 my $defaultValue = $parameter->default; 4491 4458 4492 4459 # String-related optimizations. 4493 if ($codeGenerator->IsStringType($ type)) {4460 if ($codeGenerator->IsStringType($idlType)) { 4494 4461 my $useAtomicString = $parameter->extendedAttributes->{AtomicString}; 4495 4462 if ($defaultValue eq "null") { … … 4523 4490 if ($shouldPassByReference) { 4524 4491 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"); 4526 4493 $value = $isTearOff ? "$name->propertyReference()" : "*$name"; 4527 4494 } 4528 4495 4529 if ($codeGenerator->IsTypedArrayType($ type) and $parameter->type ne "ArrayBuffer") {4496 if ($codeGenerator->IsTypedArrayType($idlType) and $idlType->name ne "ArrayBuffer") { 4530 4497 $value = $shouldPassByReference ? "$name.releaseNonNull()" : "WTFMove($name)"; 4531 } elsif ($codeGenerator->IsDictionaryType($ type)) {4498 } elsif ($codeGenerator->IsDictionaryType($idlType)) { 4532 4499 $value = "WTFMove($name)"; 4533 4500 } … … 4540 4507 push @arguments, GenerateReturnParameters($function); 4541 4508 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}; 4543 4510 4544 4511 return ($functionString, scalar @arguments); … … 4558 4525 { 4559 4526 my ($object, $dictionary, $className, $enumerations) = @_; 4560 4561 my $dictionaryName = $dictionary->name;4562 4527 4563 4528 # - Add default header template and header protection. … … 4578 4543 if ($writeDependencies) { 4579 4544 my @ancestors; 4580 my $parent Name = $dictionary->parent;4581 while (defined($parent Name)) {4582 push(@ancestors, $parent Name) if $codeGenerator->IsExternalDictionaryType($parentName);4583 my $parentDictionary = $codeGenerator->GetDictionaryBy Name($parentName);4584 assert("Unable to find definition for dictionary named '" . $parent Name . "'!") unless $parentDictionary;4585 $parent Name = $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; 4586 4551 } 4587 4552 push(@depsContent, "$className.h : ", join(" ", map { "$_.idl" } @ancestors), "\n"); … … 4649 4614 my @arguments = (); 4650 4615 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"); 4654 4619 } 4655 4620 } … … 4781 4746 foreach my $function (@{$interface->functions}) { 4782 4747 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") { 4784 4749 next; 4785 4750 } 4786 4751 4787 Add IncludesForTypeInImpl($function->signature->type);4752 AddToImplIncludesForIDLType($function->signature->idlType); 4788 4753 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}("); 4790 4755 4791 4756 my @args = (); … … 4793 4758 foreach my $param (@params) { 4794 4759 my $paramName = $param->name; 4795 Add IncludesForTypeInImpl($param->type, 1);4796 push(@args, GetNativeTypeForCallbacks($interface, $param-> type) . " " . $paramName);4760 AddToImplIncludesForIDLType($param->idlType, 1); 4761 push(@args, GetNativeTypeForCallbacks($interface, $param->idlType) . " " . $paramName); 4797 4762 } 4798 4763 push(@implContent, join(", ", @args)); … … 4862 4827 my $mayThrowLegacyException = $function->signature->extendedAttributes->{MayThrowLegacyException}; 4863 4828 4864 if ($function->signature-> type eq "void" || IsReturningPromise($function)) {4829 if ($function->signature->idlType->name eq "void" || IsReturningPromise($function)) { 4865 4830 if ($nondeterministic) { 4866 4831 AddToImplIncludes("<replay/InputCursor.h>", "WEB_REPLAY"); … … 4898 4863 4899 4864 my $nativeType = GetNativeTypeFromSignature($interface, $function->signature); 4900 my $memoizedType = GetNativeTypeForMemoization($interface, $function->signature-> type);4865 my $memoizedType = GetNativeTypeForMemoization($interface, $function->signature->idlType); 4901 4866 my $bindingName = $interface->name . "." . $function->signature->name; 4902 4867 push(@implContent, $indent . "JSValue result;\n"); … … 5053 5018 my ($interface, $signature) = @_; 5054 5019 5055 return GetNativeType($interface, $signature-> type);5020 return GetNativeType($interface, $signature->idlType); 5056 5021 } 5057 5022 … … 5082 5047 sub GetNativeVectorType 5083 5048 { 5084 my ($ interface, $type) = @_;5049 my ($type) = @_; 5085 5050 5086 5051 die "This should only be called for sequence or array types" unless $codeGenerator->IsSequenceOrFrozenArrayType($type); … … 5170 5135 5171 5136 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); 5176 5141 return "IDLUnion<" . join(", ", GetIDLUnionMemberTypes($interface, $idlType)) . ">" if $idlType->isUnion; 5177 5142 return "IDLInterface<" . $idlType->name . ">"; … … 5191 5156 my ($interface, $type) = @_; 5192 5157 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}; 5194 5163 5195 5164 return GetEnumerationClassName($type, $interface) if $codeGenerator->IsEnumType($type); 5196 5165 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); 5199 5169 return "${tearOffType}*" if $tearOffType; 5200 5170 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}*"; 5206 5173 } 5207 5174 5208 5175 sub ShouldPassWrapperByReference 5209 5176 { 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); 5214 5180 return $codeGenerator->ShouldPassWrapperByReference($parameter, $interface) && (substr($nativeType, -1) eq '*' || $nativeType =~ /^RefPtr/); 5215 5181 } … … 5219 5185 my $innerType = shift; 5220 5186 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>"; 5223 5191 } 5224 5192 … … 5227 5195 my ($interface, $type) = @_; 5228 5196 5229 return "RefPtr<SerializedScriptValue>&&" if $type eq "SerializedScriptValue";5197 return "RefPtr<SerializedScriptValue>&&" if $type->name eq "SerializedScriptValue"; 5230 5198 return "const String&" if $codeGenerator->IsStringType($type); 5231 5199 return GetNativeType($interface, $type); … … 5241 5209 sub GetSVGPropertyTypes 5242 5210 { 5243 my $implType = shift; 5211 my $interface = shift; 5212 5213 my $interfaceName = $interface->name; 5244 5214 5245 5215 my $svgPropertyType; … … 5247 5217 my $svgNativeType; 5248 5218 5249 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $i mplType =~ /SVG/;5250 5251 $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff ($implType);5219 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $interfaceName =~ /SVG/; 5220 5221 $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOffForType($interface->type); 5252 5222 return ($svgPropertyType, $svgListPropertyType, $svgNativeType) if not $svgNativeType; 5253 5223 5254 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff ($implType);5224 my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOffForType($interface->type); 5255 5225 if ($svgNativeType =~ /SVGPropertyTearOff/) { 5256 5226 $svgPropertyType = $svgWrappedNativeType; … … 5279 5249 { 5280 5250 my $type = shift; 5281 return exists $nativeType{$type}; 5251 5252 return exists $nativeType{$type->name}; 5282 5253 } 5283 5254 … … 5310 5281 return 1 if $idlType->name eq "Date"; 5311 5282 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); 5317 5288 return 0; 5318 5289 } … … 5324 5295 my ($interface, $signature, $value, $conditional, $statePointer, $stateReference, $thisObjectReference) = @_; 5325 5296 5326 my $type = $signature->type;5327 5297 my $idlType = $signature->idlType; 5328 5298 … … 5341 5311 push(@conversionArguments, "$stateReference"); 5342 5312 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); 5345 5315 5346 5316 return ("convert<$IDLType>(" . join(", ", @conversionArguments) . ")", 1); 5347 5317 } 5348 5318 5349 if ($ type eq "DOMString") {5319 if ($idlType->name eq "DOMString") { 5350 5320 return ("AtomicString($value.toString($statePointer)->toExistingAtomicString($statePointer))", 1) if $signature->extendedAttributes->{RequiresExistingAtomicString}; 5351 5321 return ("$value.toString($statePointer)->toAtomicString($statePointer)", 1) if $signature->extendedAttributes->{AtomicString}; … … 5353 5323 } 5354 5324 5355 if ($ type eq "SerializedScriptValue") {5325 if ($idlType->name eq "SerializedScriptValue") { 5356 5326 AddToImplIncludes("SerializedScriptValue.h", $conditional); 5357 5327 return ("SerializedScriptValue::create($stateReference, $value)", 1); 5358 5328 } 5359 5329 5360 if ($ type eq "Dictionary") {5330 if ($idlType->name eq "Dictionary") { 5361 5331 AddToImplIncludes("Dictionary.h", $conditional); 5362 5332 return ("Dictionary($statePointer, $value)", 0); 5363 5333 } 5364 5334 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); 5373 5339 5374 5340 # 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); 5380 5346 } 5381 5347 … … 5387 5353 return 1 if $idlType->name eq "boolean"; 5388 5354 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); 5393 5360 return 1 if $idlType->isUnion; 5394 return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);5395 5361 5396 5362 return 0; … … 5403 5369 # FIXME: This should actually check if all the sub-objects of the union need the state. 5404 5370 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); 5408 5374 return 1 if $idlType->name eq "Date"; 5409 5375 … … 5417 5383 # FIXME: This should actually check if all the sub-objects of the union need the global object. 5418 5384 return 1 if $idlType->isUnion; 5419 return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType ->name);5385 return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType); 5420 5386 5421 5387 return 0; … … 5450 5416 5451 5417 my $conditional = $signature->extendedAttributes->{Conditional}; 5452 my $type = $signature->type;5453 5418 my $idlType = $signature->idlType; 5454 5419 my $isNullable = $signature->isNullable; … … 5457 5422 # We could instead overload a function to work with optional as well as non-optional numbers, but this 5458 5423 # 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")) { 5460 5425 $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g; 5461 5426 $value = "std::max(0, $value)"; 5462 5427 } 5463 5428 5464 if ($ type eq "any") {5429 if ($idlType->name eq "any") { 5465 5430 my $returnType = $signature->extendedAttributes->{ImplementationReturnType}; 5466 5431 if (defined $returnType and ($returnType eq "IDBKeyPath" or $returnType eq "IDBKey")) { … … 5485 5450 } 5486 5451 5487 if ($ type eq "SerializedScriptValue") {5452 if ($idlType->name eq "SerializedScriptValue") { 5488 5453 AddToImplIncludes("SerializedScriptValue.h", $conditional); 5489 5454 return "$value ? $value->deserialize($stateReference, $globalObject) : jsNull()"; 5490 5455 } 5491 5456 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")) { 5499 5464 # 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())"; 5501 5466 } elsif ($interface->name eq "SVGViewSpec") { 5502 5467 # 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}) { 5507 5472 my $getter = $value; 5508 5473 $getter =~ s/impl\.//; … … 5511 5476 my $updateMethod = "&" . $interface->name . "::update" . $codeGenerator->WK_ucfirst($getter); 5512 5477 5513 my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff ($interface->name);5478 my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOffForType($interface->type); 5514 5479 if ($selfIsTearOffType) { 5515 5480 # FIXME: Why SVGMatrix specifically? … … 5728 5693 my $checkType = $include; 5729 5694 $checkType =~ s/\.h//; 5730 next if $codeGenerator->IsSVGAnimatedType ($checkType);5695 next if $codeGenerator->IsSVGAnimatedTypeName($checkType); 5731 5696 5732 5697 $include = "\"$include\"" unless $include =~ /^["<]/; # " … … 6058 6023 # so we should be able to use our parent's interface object no matter what. However, some of our IDL files (e.g. CanvasRenderingContext2D) 6059 6024 # 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}) { 6061 6026 my $parentClassName = "JS" . $interface->parent; 6062 6027 push(@$outputArray, " return ${parentClassName}::getConstructor(vm, &globalObject);\n"); … … 6138 6103 { 6139 6104 my $function = shift; 6140 return $function->signature-> type && $function->signature->type eq "Promise";6105 return $function->signature->idlType && $function->signature->idlType->name eq "Promise"; 6141 6106 } 6142 6107 -
trunk/Source/WebCore/bindings/scripts/IDLParser.pm
r207829 r208023 55 55 struct( domInterface => { 56 56 name => '$', # Class identifier 57 type => '$', # Class type 57 58 parent => '$', # Parent class identifier 58 parent s => '@', # Parent class identifiers (Kept for compatibility with ObjC bindings)59 parentType => '$', # Parent class type 59 60 constants => '@', # List of 'domConstant' 60 61 functions => '@', # List of 'domFunction' … … 91 92 direction => '$', # Variable direction (in or out) 92 93 name => '$', # Variable name 93 type => '$', # Variable type name (DEPRECATED - please use idlType)94 94 idlType => '$', # Variable type 95 95 specials => '@', # Specials … … 123 123 # Used to represent string constants 124 124 struct( domConstant => { 125 name => '$', 126 type => '$', # Type of data127 value => '$', 125 name => '$', # DOM Constant identifier 126 type => '$', # Type name of data 127 value => '$', # Constant value 128 128 extendedAttributes => '$', # Extended attributes 129 129 }); … … 132 132 struct( domEnum => { 133 133 name => '$', # Enumeration identifier 134 type => '$', # Enumeration type 134 135 values => '@', # Enumeration values (list of unique strings) 135 136 extendedAttributes => '$', … … 137 138 138 139 struct( 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 141 144 members => '@', # List of 'domSignature' 142 145 extendedAttributes => '$', … … 361 364 my $type = shift; 362 365 $type =~ s/^_//; 366 return $type; 367 } 368 369 sub makeSimpleType 370 { 371 my $typeName = shift; 372 373 my $type = domType->new(); 374 $type->name($typeName); 375 363 376 return $type; 364 377 } … … 478 491 my $numberOfSubtypes = scalar @{$signature->idlType->subtypes}; 479 492 if ($numberOfSubtypes) { 480 my $typeUpdated = 0;481 482 493 for my $i (0..$numberOfSubtypes - 1) { 483 494 my $subtype = @{$signature->idlType->subtypes}[$i]; … … 493 504 494 505 @{$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);512 506 } 513 507 } … … 525 519 526 520 $signature->idlType($clonedType); 527 $signature->type($clonedType->name);528 521 $signature->isNullable($clonedType->isNullable); 529 522 … … 606 599 my $interfaceNameToken = $self->getToken(); 607 600 $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 612 613 $self->assertTokenValue($self->getToken(), "{", __LINE__); 613 614 my $interfaceMembers = $self->parseInterfaceMembers(); … … 716 717 $dictionary->extendedAttributes($extendedAttributeList); 717 718 $self->assertTokenValue($self->getToken(), "dictionary", __LINE__); 719 718 720 my $nameToken = $self->getToken(); 719 721 $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 723 734 $self->assertTokenValue($self->getToken(), "{", __LINE__); 724 735 $dictionary->members($self->parseDictionaryMembers()); … … 767 778 my $type = $self->parseType(); 768 779 $member->idlType($type); 769 $member->type($type->name);770 780 $member->isNullable($type->isNullable); 771 781 … … 836 846 my $exceptionNameToken = $self->getToken(); 837 847 $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)); 839 852 $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 843 861 $self->assertTokenValue($self->getToken(), "{", __LINE__); 844 862 my $exceptionMembers = $self->parseExceptionMembers(); … … 876 894 { 877 895 my $self = shift; 878 my @parent = ();879 896 880 897 my $next = $self->nextToken(); 881 898 if ($next->value() eq ":") { 882 899 $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__); 890 903 } 891 904 … … 901 914 my $enumNameToken = $self->getToken(); 902 915 $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)); 904 919 $self->assertTokenValue($self->getToken(), "{", __LINE__); 905 920 push(@{$enum->values}, @{$self->parseEnumValueList()}); … … 1016 1031 my $newDataNode = domConstant->new(); 1017 1032 $self->assertTokenValue($self->getToken(), "const", __LINE__); 1018 1019 1033 my $type = $self->parseConstType(); 1020 $newDataNode->type($type->name); 1021 1034 $newDataNode->type($type); 1022 1035 my $constNameToken = $self->getToken(); 1023 1036 $self->assertTokenType($constNameToken, IdentifierToken); … … 1287 1300 if (defined ($interface)) { 1288 1301 $interface->signature->idlType($returnType); 1289 $interface->signature->type($returnType->name);1290 1302 $interface->signature->isNullable($returnType->isNullable); 1291 1303 } … … 1327 1339 my $type = $self->parseType(); 1328 1340 $newDataNode->signature->idlType($type); 1329 $newDataNode->signature->type($type->name);1330 1341 $newDataNode->signature->isNullable($type->isNullable); 1331 1342 … … 1385 1396 my $operation = $self->parseOperationRest($extendedAttributeList); 1386 1397 $operation->signature->idlType($returnType); 1387 $operation->signature->type($returnType->name);1388 1398 $operation->signature->isNullable($returnType->isNullable); 1389 1399 … … 1407 1417 if (defined ($interface)) { 1408 1418 $interface->signature->idlType($returnType); 1409 $interface->signature->type($returnType->name);1410 1419 $interface->signature->isNullable($returnType->isNullable); 1411 1420 $interface->signature->specials(\@specials); … … 1505 1514 my $forEachArgument = domSignature->new(); 1506 1515 $forEachArgument->name("callback"); 1507 $forEachArgument-> type("any");1516 $forEachArgument->idlType(makeSimpleType("any")); 1508 1517 push(@{$forEachFunction->parameters}, ($forEachArgument)); 1509 1518 … … 1628 1637 my $type = $self->parseType(); 1629 1638 $paramDataNode->idlType($type); 1630 $paramDataNode->type(identifierRemoveNullablePrefix($type->name));1631 1639 $paramDataNode->isNullable($type->isNullable); 1632 1640 $paramDataNode->isOptional(1); … … 1638 1646 my $type = $self->parseType(); 1639 1647 $paramDataNode->idlType($type); 1640 $paramDataNode->type($type->name);1641 1648 $paramDataNode->isNullable($type->isNullable); 1642 1649 $paramDataNode->isOptional(0); … … 1701 1708 my $type = $self->parseType(); 1702 1709 $newDataNode->signature->idlType($type); 1703 $newDataNode->signature->type($type->name);1704 1710 $newDataNode->signature->isNullable($type->isNullable); 1705 1711 … … 2117 2123 $self->assertTokenValue($self->getToken(), ">", __LINE__); 2118 2124 2119 # FIXME: This should just be "sequence" when we start using domTypes in the CodeGenerators 2120 $type->name("sequence<${subtypeName}>"); 2125 $type->name("sequence"); 2121 2126 push(@{$type->subtypes}, $subtype); 2122 2127 … … 2132 2137 $self->assertTokenValue($self->getToken(), ">", __LINE__); 2133 2138 2134 # FIXME: This should just be "FrozenArray" when we start using domTypes in the CodeGenerators 2135 $type->name("FrozenArray<${subtypeName}>"); 2139 $type->name("FrozenArray"); 2136 2140 push(@{$type->subtypes}, $subtype); 2137 2141 … … 2350 2354 # here to determine serializability: https://heycam.github.io/webidl/#idl-serializers 2351 2355 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/; 2353 2357 } 2354 2358 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
r207912 r208023 27 27 #include "JSDOMConvert.h" 28 28 #include "JSNode.h" 29 #include "Node.h"30 29 #include "wtf/text/AtomicString.h" 31 30 #include <runtime/Error.h> -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
r207912 r208023 29 29 #include "JSDOMConstructor.h" 30 30 #include "JSDOMConvert.h" 31 #include " TestObj.h"31 #include "JSTestObj.h" 32 32 #include "TestSupplemental.h" 33 33 #include <runtime/Error.h> … … 41 41 #if ENABLE(Condition11) || ENABLE(Condition12) || ENABLE(Condition22) || ENABLE(Condition23) 42 42 #include "JSNode.h" 43 #include "JSTestObj.h"44 43 #endif 45 44 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r207937 r208023 23 23 24 24 #include "CallbackFunction.h" 25 #include "DOMStringList.h"26 25 #include "Dictionary.h" 27 26 #include "Document.h" 28 #include "Element.h"29 27 #include "EventNames.h" 30 28 #include "ExceptionCode.h" … … 57 55 #include "JSXPathNSResolver.h" 58 56 #include "RuntimeEnabledFeatures.h" 59 #include "SVGDocument.h"60 #include "SVGPoint.h"61 57 #include "SVGStaticPropertyTearOff.h" 62 58 #include "SerializedScriptValue.h" -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp
r207912 r208023 28 28 #include <runtime/Error.h> 29 29 #include <runtime/FunctionPrototype.h> 30 #include <runtime/JSArray.h> 30 31 #include <wtf/GetPtr.h> 31 32 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp
r207912 r208023 27 27 #include "JSDOMConvert.h" 28 28 #include "JSNode.h" 29 #include "Node.h"30 29 #include "wtf/text/AtomicString.h" 31 30 #include <runtime/Error.h> -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp
r207737 r208023 31 31 #include "SerializedScriptValue.h" 32 32 #include <runtime/FunctionPrototype.h> 33 #include <runtime/JSArray.h> 33 34 #include <wtf/GetPtr.h> 34 35 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
r207912 r208023 30 30 #include "JSTestEventTarget.h" 31 31 #include "JSTestSubObj.h" 32 #include "SVGPoint.h"33 32 #include "SerializedScriptValue.h" 34 33 #include <runtime/Error.h> -
trunk/Source/WebCore/html/HTMLEmbedElement.idl
r206723 r208023 24 24 CustomCall, 25 25 ] 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; 32 32 33 [CheckSecurityForNode, MayThrowLegacyException] SVGDocument getSVGDocument();33 [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument(); 34 34 }; 35 35 -
trunk/Source/WebCore/html/HTMLFrameElement.idl
r206723 r208023 38 38 readonly attribute DOMWindow contentWindow; 39 39 40 [CheckSecurityForNode, MayThrowLegacyException] SVGDocument getSVGDocument();40 [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument(); 41 41 42 42 // FIXME: No other browser has this attribute. -
trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp
r207458 r208023 113 113 } 114 114 115 SVGDocument* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const115 Document* HTMLFrameOwnerElement::getSVGDocument(ExceptionCode& ec) const 116 116 { 117 117 Document* document = contentDocument(); -
trunk/Source/WebCore/html/HTMLFrameOwnerElement.h
r207458 r208023 50 50 RenderWidget* renderWidget() const; 51 51 52 SVGDocument* getSVGDocument(ExceptionCode&) const;52 Document* getSVGDocument(ExceptionCode&) const; 53 53 54 54 virtual ScrollbarMode scrollingMode() const { return ScrollbarAuto; } -
trunk/Source/WebCore/html/HTMLIFrameElement.idl
r207355 r208023 42 42 readonly attribute DOMWindow contentWindow; 43 43 44 [CheckSecurityForNode, MayThrowLegacyException] SVGDocument getSVGDocument();44 [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument(); 45 45 }; 46 46 -
trunk/Source/WebCore/html/HTMLObjectElement.idl
r207426 r208023 51 51 [CheckSecurityForNode] readonly attribute Document contentDocument; 52 52 53 [CheckSecurityForNode, MayThrowLegacyException] SVGDocument getSVGDocument();53 [CheckSecurityForNode, MayThrowLegacyException] Document getSVGDocument(); 54 54 }; 55 55 -
trunk/Tools/ChangeLog
r207998 r208023 1 2016-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 1 12 2016-10-27 Commit Queue <commit-queue@webkit.org> 2 13 -
trunk/Tools/DumpRenderTree/Bindings/CodeGeneratorDumpRenderTree.pm
r206851 r208023 64 64 { 65 65 my ($self, $idlType) = @_; 66 66 67 return $$self{codeGenerator}->WK_lcfirst(_implementationClassName($idlType)) . "Class"; 67 68 } … … 142 143 my @contents = (); 143 144 144 my $idlType = $interface-> name;145 my $idlType = $interface->type; 145 146 my $className = _className($idlType); 146 147 my $implementationClassName = _implementationClassName($idlType); … … 209 210 my @contents = (); 210 211 211 my $idlType = $interface-> name;212 my $idlType = $interface->type; 212 213 my $className = _className($idlType); 213 214 my $implementationClassName = _implementationClassName($idlType); … … 284 285 my @specifiedParameters = @{$function->parameters}; 285 286 286 $self->_includeHeaders(\%contentsIncludes, $function->signature-> type, $function->signature);287 $self->_includeHeaders(\%contentsIncludes, $function->signature->idlType, $function->signature); 287 288 288 289 if ($function->signature->extendedAttributes->{"PassContext"}) { … … 303 304 } 304 305 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"; 306 307 push(@contents, " return " . $self->_returnExpression($function->signature, $functionCall) . ";\n}\n"); 307 308 } … … 311 312 push(@contents, "\n// Attributes\n"); 312 313 foreach my $attribute (@attributes) { 313 $self->_includeHeaders(\%contentsIncludes, $attribute->signature-> type, $attribute->signature);314 $self->_includeHeaders(\%contentsIncludes, $attribute->signature->idlType, $attribute->signature); 314 315 315 316 my $getterName = $self->_getterName($attribute); … … 368 369 my ($self, $attribute) = @_; 369 370 370 my $signature = $attribute->signature; 371 my $name = $signature->name; 372 373 return $name; 371 return $attribute->signature->name; 374 372 } 375 373 … … 379 377 380 378 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"; 383 381 return if $$self{codeGenerator}->IsNonPointerType($idlType); 384 382 return if $$self{codeGenerator}->IsStringType($idlType); … … 392 390 my ($idlType) = @_; 393 391 394 return $idlType ;392 return $idlType->name; 395 393 } 396 394 … … 414 412 { 415 413 my ($interface) = @_; 416 return $interface->parent ;414 return $interface->parentType; 417 415 } 418 416 … … 423 421 return undef unless defined $idlType; 424 422 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"; 427 425 return "JSRetainPtr<JSStringRef>" if $$self{codeGenerator}->IsStringType($idlType); 428 426 return "double" if $$self{codeGenerator}->IsNonPointerType($idlType); … … 434 432 my ($self, $signature, $argumentName) = @_; 435 433 436 my $idlType = $signature-> type;434 my $idlType = $signature->idlType; 437 435 438 436 return "JSValueToBoolean(context, $argumentName)" if $idlType eq "boolean"; 439 return "$argumentName" if $idlType eq "object";437 return "$argumentName" if $idlType->name eq "object"; 440 438 return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($idlType); 441 439 return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsNonPointerType($idlType); … … 447 445 my ($self, $signature, $variableName, $argumentName, $condition) = @_; 448 446 449 my $platformType = $self->_platformType($signature-> type, $signature);447 my $platformType = $self->_platformType($signature->idlType, $signature); 450 448 my $constructor = $self->_platformTypeConstructor($signature, $argumentName); 451 449 … … 475 473 my ($self, $signature, $expression) = @_; 476 474 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"; 482 480 return "JSValueMakeNumber(context, ${expression})" if $$self{codeGenerator}->IsNonPointerType($returnIDLType); 483 481 return "JSValueMakeStringOrNull(context, ${expression}.get())" if $$self{codeGenerator}->IsStringType($returnIDLType); … … 489 487 my ($self, $parameter) = @_; 490 488 491 my $idlType = $parameter-> type;489 my $idlType = $parameter->idlType; 492 490 my $name = $parameter->name; 493 491 … … 524 522 my ($self, $interface, $functionOrValue, $arrayTerminator, $mapFunction, $functionsOrAttributes) = @_; 525 523 526 my $className = _className($interface-> name);524 my $className = _className($interface->type); 527 525 my $uppercaseFunctionOrValue = $$self{codeGenerator}->WK_ucfirst($functionOrValue); 528 526 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm
r206851 r208023 29 29 package CodeGeneratorTestRunner; 30 30 31 use Carp qw<longmess>; 32 use Data::Dumper; 33 34 sub assert 35 { 36 my $message = shift; 37 38 my $mess = longmess(); 39 print Dumper($mess); 40 41 die $message; 42 } 43 31 44 sub new 32 45 { … … 58 71 { 59 72 my ($idlType) = @_; 73 74 assert("Not a type") if ref($idlType) ne "domType"; 60 75 61 76 return "JS" . _implementationClassName($idlType); … … 143 158 my @contents = (); 144 159 145 my $idlType = $interface-> name;160 my $idlType = $interface->type; 146 161 my $className = _className($idlType); 147 162 my $implementationClassName = _implementationClassName($idlType); … … 210 225 my @contents = (); 211 226 212 my $idlType = $interface-> name;227 my $idlType = $interface->type; 213 228 my $className = _className($idlType); 214 229 my $implementationClassName = _implementationClassName($idlType); … … 245 260 if (!jsClass) { 246 261 JSClassDefinition definition = kJSClassDefinitionEmpty; 247 definition.className = " ${idlType}";262 definition.className = "@{[$idlType->name]}"; 248 263 definition.parentClass = @{[$self->_parentClassRefGetterExpression($interface)]}; 249 264 definition.staticValues = staticValues(); … … 285 300 my @specifiedParameters = @{$function->parameters}; 286 301 287 $self->_includeHeaders(\%contentsIncludes, $function->signature-> type, $function->signature);302 $self->_includeHeaders(\%contentsIncludes, $function->signature->idlType, $function->signature); 288 303 289 304 if ($function->signature->extendedAttributes->{"PassContext"}) { … … 304 319 } 305 320 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"; 307 322 push(@contents, " return " . $self->_returnExpression($function->signature, $functionCall) . ";\n}\n"); 308 323 } … … 312 327 push(@contents, "\n// Attributes\n"); 313 328 foreach my $attribute (@attributes) { 314 $self->_includeHeaders(\%contentsIncludes, $attribute->signature-> type, $attribute->signature);329 $self->_includeHeaders(\%contentsIncludes, $attribute->signature->idlType, $attribute->signature); 315 330 316 331 my $getterName = $self->_getterName($attribute); … … 369 384 my ($self, $attribute) = @_; 370 385 371 my $signature = $attribute->signature; 372 my $name = $signature->name; 373 374 return $name; 386 return $attribute->signature->name; 375 387 } 376 388 … … 380 392 381 393 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"; 384 396 return if $$self{codeGenerator}->IsNonPointerType($idlType); 385 397 return if $$self{codeGenerator}->IsStringType($idlType); … … 393 405 my ($idlType) = @_; 394 406 395 return $idlType ;407 return $idlType->name; 396 408 } 397 409 … … 415 427 { 416 428 my ($interface) = @_; 417 return $interface->parent ;429 return $interface->parentType; 418 430 } 419 431 … … 424 436 return undef unless defined $idlType; 425 437 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"; 428 440 return "JSRetainPtr<JSStringRef>" if $$self{codeGenerator}->IsStringType($idlType); 429 441 return "double" if $$self{codeGenerator}->IsNonPointerType($idlType); … … 435 447 my ($self, $signature, $argumentName) = @_; 436 448 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"; 441 453 return "JSRetainPtr<JSStringRef>(Adopt, JSValueToStringCopy(context, $argumentName, 0))" if $$self{codeGenerator}->IsStringType($idlType); 442 454 return "JSValueToNumber(context, $argumentName, 0)" if $$self{codeGenerator}->IsNonPointerType($idlType); … … 448 460 my ($self, $signature, $variableName, $argumentName, $condition) = @_; 449 461 450 my $platformType = $self->_platformType($signature-> type, $signature);462 my $platformType = $self->_platformType($signature->idlType, $signature); 451 463 my $constructor = $self->_platformTypeConstructor($signature, $argumentName); 452 464 … … 476 488 my ($self, $signature, $expression) = @_; 477 489 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"; 483 495 return "JSValueMakeNumber(context, ${expression})" if $$self{codeGenerator}->IsNonPointerType($returnIDLType); 484 496 return "JSValueMakeStringOrNull(context, ${expression}.get())" if $$self{codeGenerator}->IsStringType($returnIDLType); … … 490 502 my ($self, $parameter) = @_; 491 503 492 my $idlType = $parameter-> type;504 my $idlType = $parameter->idlType; 493 505 my $name = $parameter->name; 494 506 … … 525 537 my ($self, $interface, $functionOrValue, $arrayTerminator, $mapFunction, $functionsOrAttributes) = @_; 526 538 527 my $className = _className($interface-> name);539 my $className = _className($interface->type); 528 540 my $uppercaseFunctionOrValue = $$self{codeGenerator}->WK_ucfirst($functionOrValue); 529 541
Note: See TracChangeset
for help on using the changeset viewer.