Changeset 58296 in webkit
- Timestamp:
- Apr 27, 2010 1:02:36 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r58295 r58296 1 2010-04-27 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 Move code out of GenerateImplementation to make it more smaller 6 https://bugs.webkit.org/show_bug.cgi?id=38176 7 8 * bindings/scripts/CodeGeneratorJS.pm: 9 - Move some code into a new GenerateAttributesHashTable method. 10 1 11 2010-04-26 Adam Barth <abarth@webkit.org> 2 12 -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r58295 r58296 936 936 } 937 937 938 sub GenerateAttributesHashTable($$) 939 { 940 my ($object, $dataNode) = @_; 941 942 # FIXME: These should be functions on $dataNode. 943 my $interfaceName = $dataNode->name; 944 my $className = "JS$interfaceName"; 945 946 # - Add all attributes in a hashtable definition 947 my $numAttributes = @{$dataNode->attributes}; 948 $numAttributes++ if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})); 949 950 return 0 if !$numAttributes; 951 952 my $hashSize = $numAttributes; 953 my $hashName = $className . "Table"; 954 955 my @hashKeys = (); 956 my @hashSpecials = (); 957 my @hashValue1 = (); 958 my @hashValue2 = (); 959 my %conditionals = (); 960 961 my @entries = (); 962 963 foreach my $attribute (@{$dataNode->attributes}) { 964 my $name = $attribute->signature->name; 965 push(@hashKeys, $name); 966 967 my @specials = (); 968 push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; 969 push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"DontEnum"}; 970 push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; 971 my $special = (@specials > 0) ? join("|", @specials) : "0"; 972 push(@hashSpecials, $special); 973 974 my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); 975 push(@hashValue1, $getter); 976 977 if ($attribute->type =~ /readonly/) { 978 push(@hashValue2, "0"); 979 } else { 980 my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); 981 push(@hashValue2, $setter); 982 } 983 984 my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; 985 if ($conditional) { 986 $conditionals{$name} = $conditional; 987 } 988 } 989 990 if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { 991 push(@hashKeys, "constructor"); 992 my $getter = "js" . $interfaceName . "Constructor"; 993 push(@hashValue1, $getter); 994 push(@hashValue2, "0"); 995 push(@hashSpecials, "DontEnum|ReadOnly"); # FIXME: Setting the constructor should be possible. 996 } 997 998 $object->GenerateHashTable($hashName, $hashSize, 999 \@hashKeys, \@hashSpecials, 1000 \@hashValue1, \@hashValue2, 1001 \%conditionals); 1002 return $numAttributes; 1003 } 1004 938 1005 sub GenerateImplementation 939 1006 { … … 974 1041 push(@implContent, "ASSERT_CLASS_FITS_IN_CELL($className);\n\n"); 975 1042 976 # - Add all attributes in a hashtable definition 977 my $numAttributes = @{$dataNode->attributes}; 978 $numAttributes++ if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})); 979 980 if ($numAttributes > 0) { 981 my $hashSize = $numAttributes; 982 my $hashName = $className . "Table"; 983 984 my @hashKeys = (); 985 my @hashSpecials = (); 986 my @hashValue1 = (); 987 my @hashValue2 = (); 988 my %conditionals = (); 989 990 my @entries = (); 991 992 foreach my $attribute (@{$dataNode->attributes}) { 993 my $name = $attribute->signature->name; 994 push(@hashKeys, $name); 995 996 my @specials = (); 997 push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; 998 push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"DontEnum"}; 999 push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; 1000 my $special = (@specials > 0) ? join("|", @specials) : "0"; 1001 push(@hashSpecials, $special); 1002 1003 my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); 1004 push(@hashValue1, $getter); 1005 1006 if ($attribute->type =~ /readonly/) { 1007 push(@hashValue2, "0"); 1008 } else { 1009 my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); 1010 push(@hashValue2, $setter); 1011 } 1012 1013 my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; 1014 if ($conditional) { 1015 $conditionals{$name} = $conditional; 1016 } 1017 } 1018 1019 if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { 1020 push(@hashKeys, "constructor"); 1021 my $getter = "js" . $interfaceName . "Constructor"; 1022 push(@hashValue1, $getter); 1023 push(@hashValue2, "0"); 1024 push(@hashSpecials, "DontEnum|ReadOnly"); # FIXME: Setting the constructor should be possible. 1025 } 1026 1027 $object->GenerateHashTable($hashName, $hashSize, 1028 \@hashKeys, \@hashSpecials, 1029 \@hashValue1, \@hashValue2, 1030 \%conditionals); 1031 } 1043 my $numAttributes = GenerateAttributesHashTable($object, $dataNode); 1032 1044 1033 1045 my $numConstants = @{$dataNode->constants};
Note: See TracChangeset
for help on using the changeset viewer.