Changeset 162872 in webkit
- Timestamp:
- Jan 27, 2014 3:15:17 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r162871 r162872 1 2014-01-27 Andy Estes <aestes@apple.com> 2 3 Stop the code generator from adding ENABLE() macros to Objective-C DOM headers 4 https://bugs.webkit.org/show_bug.cgi?id=127706 5 6 Reviewed by David Kilzer. 7 8 Instead of adding ENABLE() macros to generated Objective-C DOM 9 headers, which might become Public or Private headers, elide generated 10 code for disabled features. 11 12 * bindings/scripts/CodeGeneratorObjC.pm: 13 (GenerateInterface): Passed $defines to GenerateHeader. 14 (ConditionalIsEnabled): Checked if the given conditional is found in 15 $defines. Handled conditionals with '&' and '|'. 16 (GenerateHeader): Rather than calling GenerateConditionalString to 17 generate an "#if ENABLE(...)", called ConditionalIsEnabled() to see 18 whether we should generate code for the given constant, attribute, or 19 function. 20 1 21 2014-01-27 Zoltan Horvath <zoltan@webkit.org> 2 22 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm
r161878 r162872 28 28 29 29 use constant FileNamePrefix => "DOM"; 30 31 sub ConditionalIsEnabled(\%$); 30 32 31 33 # Global Variables … … 377 379 378 380 # Start actual generation.. 379 $object->GenerateHeader($interface );381 $object->GenerateHeader($interface, $defines); 380 382 $object->GenerateImplementation($interface) unless $noImpl; 381 383 … … 791 793 } 792 794 795 sub ConditionalIsEnabled(\%$) 796 { 797 my $defines = shift; 798 my $conditional = shift; 799 800 return 1 if !$conditional; 801 802 my $operator = ($conditional =~ /&/ ? '&' : ($conditional =~ /\|/ ? '|' : '')); 803 if (!$operator) { 804 return exists($defines->{"ENABLE_" . $conditional}); 805 } 806 807 my @conditions = split(/\Q$operator\E/, $conditional); 808 foreach (@conditions) { 809 my $enable = "ENABLE_" . $_; 810 return 0 if ($operator eq '&') and !exists($defines->{$enable}); 811 return 1 if ($operator eq '|') and exists($defines->{$enable}); 812 } 813 814 return $operator eq '&'; 815 } 816 793 817 sub GenerateHeader 794 818 { 795 819 my $object = shift; 796 820 my $interface = shift; 821 my $defines = shift; 822 823 my %definesRef = map { $_ => 1 } split(/\s+/, $defines); 797 824 798 825 my $interfaceName = $interface->name; … … 852 879 my $constantName = $constant->name; 853 880 my $constantValue = $constant->value; 854 my $conditional = $constant->extendedAttributes->{"Conditional"};855 881 my $notLast = $constant ne $constants[-1]; 856 857 if ($conditional) { 858 my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); 859 $combinedConstants .= "#if ${conditionalString}\n"; 860 } 861 $combinedConstants .= " DOM_$constantName = $constantValue"; 862 $combinedConstants .= "," if $notLast; 863 if ($conditional) { 864 $combinedConstants .= "\n#endif\n"; 865 } elsif ($notLast) { 866 $combinedConstants .= "\n"; 882 883 if (ConditionalIsEnabled(%definesRef, $constant->extendedAttributes->{"Conditional"})) { 884 $combinedConstants .= " DOM_$constantName = $constantValue"; 885 $combinedConstants .= "," if $notLast; 886 if ($notLast) { 887 $combinedConstants .= "\n"; 888 } 867 889 } 868 890 } … … 944 966 push(@headerAttributes, $property) if $public; 945 967 push(@privateHeaderAttributes, $property) unless $public; 946 } else { 947 my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); 948 if ($attributeConditionalString) { 949 push(@headerAttributes, "#if ${attributeConditionalString}\n") if $public; 950 push(@privateHeaderAttributes, "#if ${attributeConditionalString}\n") unless $public; 951 } 952 968 } elsif (ConditionalIsEnabled(%definesRef, $attribute->signature->extendedAttributes->{"Conditional"})) { 953 969 # - GETTER 954 970 my $getter = "- (" . $attributeType . ")" . $attributeName . $declarationSuffix; … … 962 978 push(@privateHeaderAttributes, $setter) unless $public; 963 979 } 964 965 if ($attributeConditionalString) {966 push(@headerAttributes, "#endif\n") if $public;967 push(@privateHeaderAttributes, "#endif\n") unless $public;968 }969 980 } 970 981 } … … 1053 1064 $inAppleCopyright{$public ? "public" : "private"} = 0; 1054 1065 } 1055 1056 my $functionConditionalString = $codeGenerator->GenerateConditionalString($function->signature); 1057 if ($functionConditionalString) { 1058 push(@headerFunctions, "#if ${functionConditionalString}\n") if $public; 1059 push(@privateHeaderFunctions, "#if ${functionConditionalString}\n") unless $public; 1060 push(@deprecatedHeaderFunctions, "#if ${functionConditionalString}\n") if $needsDeprecatedVersion; 1061 } 1062 1063 push(@headerFunctions, $functionDeclaration) if $public; 1064 push(@privateHeaderFunctions, $functionDeclaration) unless $public; 1065 1066 # generate the old style method names with un-named parameters, these methods are deprecated 1067 if ($needsDeprecatedVersion) { 1068 my $deprecatedFunctionSig = $functionSig; 1069 $deprecatedFunctionSig =~ s/\s\w+:/ :/g; # remove parameter names 1070 1071 $publicInterfaceKey = $deprecatedFunctionSig . ";"; 1072 1073 my $availabilityMacro = "WEBKIT_DEPRECATED_MAC(10_4, 10_5)"; 1074 if (defined $publicInterfaces{$publicInterfaceKey} and length $publicInterfaces{$publicInterfaceKey}) { 1075 $availabilityMacro = $publicInterfaces{$publicInterfaceKey}; 1076 } 1077 1078 $functionDeclaration = "$deprecatedFunctionSig $availabilityMacro;\n"; 1079 1080 push(@deprecatedHeaderFunctions, $functionDeclaration); 1081 1082 unless (defined $publicInterfaces{$publicInterfaceKey}) { 1083 warn "Deprecated method $publicInterfaceKey is not in PublicDOMInterfaces.h. All deprecated methods need to be public, or should have the ObjCLegacyUnnamedParameters IDL attribute removed"; 1084 $fatalError = 1; 1085 } 1086 1087 delete $publicInterfaces{$publicInterfaceKey}; 1088 } 1089 1090 if ($functionConditionalString) { 1091 push(@headerFunctions, "#endif\n") if $public; 1092 push(@privateHeaderFunctions, "#endif\n") unless $public; 1093 push(@deprecatedHeaderFunctions, "#endif\n") if $needsDeprecatedVersion; 1066 1067 if (ConditionalIsEnabled(%definesRef, $function->signature->extendedAttributes->{"Conditional"})) { 1068 push(@headerFunctions, $functionDeclaration) if $public; 1069 push(@privateHeaderFunctions, $functionDeclaration) unless $public; 1070 1071 # generate the old style method names with un-named parameters, these methods are deprecated 1072 if ($needsDeprecatedVersion) { 1073 my $deprecatedFunctionSig = $functionSig; 1074 $deprecatedFunctionSig =~ s/\s\w+:/ :/g; # remove parameter names 1075 1076 $publicInterfaceKey = $deprecatedFunctionSig . ";"; 1077 1078 my $availabilityMacro = "WEBKIT_DEPRECATED_MAC(10_4, 10_5)"; 1079 if (defined $publicInterfaces{$publicInterfaceKey} and length $publicInterfaces{$publicInterfaceKey}) { 1080 $availabilityMacro = $publicInterfaces{$publicInterfaceKey}; 1081 } 1082 1083 $functionDeclaration = "$deprecatedFunctionSig $availabilityMacro;\n"; 1084 1085 push(@deprecatedHeaderFunctions, $functionDeclaration); 1086 1087 unless (defined $publicInterfaces{$publicInterfaceKey}) { 1088 warn "Deprecated method $publicInterfaceKey is not in PublicDOMInterfaces.h. All deprecated methods need to be public, or should have the ObjCLegacyUnnamedParameters IDL attribute removed"; 1089 $fatalError = 1; 1090 } 1091 1092 delete $publicInterfaces{$publicInterfaceKey}; 1093 } 1094 1094 } 1095 1095 }
Note: See TracChangeset
for help on using the changeset viewer.