⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 94005 in webkit


Ignore:
Timestamp:
Aug 29, 2011, 1:03:33 PM (15 years ago)
Author:
Patrick Gansterer
Message:

Consider Conditional attribute in CodeGeneratorJS' JSValueToNative and NativeToJSValue function
https://bugs.webkit.org/show_bug.cgi?id=65040

Reviewed by Brent Fulgham.

JSValueToNative and NativeToJSValue add additional include statements
to the implementation and need to handle the Conditional attribute from
the IDL file. The Conditional attribute adds appropriate #if ENABLE()
lines for the preprocessor around the include statements to remove
some unneeded build dependencies.

  • bindings/scripts/CodeGeneratorJS.pm:
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r94003 r94005  
     12011-08-29  Patrick Gansterer  <paroga@webkit.org>
     2
     3        Consider Conditional attribute in CodeGeneratorJS' JSValueToNative and NativeToJSValue function
     4        https://bugs.webkit.org/show_bug.cgi?id=65040
     5
     6        Reviewed by Brent Fulgham.
     7
     8        JSValueToNative and NativeToJSValue add additional include statements
     9        to the implementation and need to handle the Conditional attribute from
     10        the IDL file. The Conditional attribute adds appropriate #if ENABLE()
     11        lines for the preprocessor around the include statements to remove
     12        some unneeded build dependencies.
     13
     14        * bindings/scripts/CodeGeneratorJS.pm:
     15
    1162011-08-29  Nate Chapin  <japhet@chromium.org>
    217
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r93980 r94005  
    310310    } elsif ($type eq "String") {
    311311        $implIncludes{"PlatformString.h"} = 1;
     312    }
     313}
     314
     315sub AddToImplIncludes
     316{
     317    my $header = shift;
     318    my $conditional = shift;
     319
     320    if (not $conditional) {
     321        $implIncludes{$header} = 1;
     322    } elsif (not exists($implIncludes{$header})) {
     323        $implIncludes{$header} = $conditional;
     324    } else {
     325        my $oldValue = $implIncludes{$header};
     326        if ($oldValue ne 1) {
     327            my %newValue = ();
     328            $newValue{$conditional} = 1;
     329            foreach my $condition (split(/\|/, $oldValue)) {
     330                $newValue{$condition} = 1;
     331            }
     332            $implIncludes{$header} = join("|", sort keys %newValue);
     333        }
    312334    }
    313335}
     
    17861808                            $constructorType =~ s/Constructor$//;
    17871809                            if ($constructorType ne "DOMObject") {
    1788                                 my $header = "JS" . $constructorType . ".h";
    1789                                 my $conditional = $attribute->signature->extendedAttributes->{"Conditional"};
    1790                                 if (not $conditional) {
    1791                                     $implIncludes{$header} = 1;
    1792                                 } elsif (not exists($implIncludes{$header})) {
    1793                                     $implIncludes{$header} = $conditional;
    1794                                 } else {
    1795                                     my $oldValue = $implIncludes{$header};
    1796                                     if ($oldValue ne 1) {
    1797                                         my %newValue = ();
    1798                                         $newValue{$conditional} = 1;
    1799                                         foreach my $condition (split(/\|/, $oldValue)) {
    1800                                             $newValue{$condition} = 1;
    1801                                         }
    1802                                         $implIncludes{$header} = join("|", sort keys %newValue);
    1803                                     }
    1804                                 }
     1810                                AddToImplIncludes("JS" . $constructorType . ".h", $attribute->signature->extendedAttributes->{"Conditional"});
    18051811                            }
    18061812                            push(@implContent, "    // Shadowing a built-in constructor\n");
     
    26312637    my $value = shift;
    26322638
     2639    my $conditional = $signature->extendedAttributes->{"Conditional"};
    26332640    my $type = $codeGenerator->StripModule($signature->type);
    26342641
     
    26542661
    26552662    if ($type eq "NodeFilter") {
    2656         $implIncludes{"JS$type.h"} = 1;
     2663        AddToImplIncludes("JS$type.h", $conditional);
    26572664        return "to$type(exec->globalData(), $value)";
    26582665    }
    26592666
    26602667    if ($type eq "MediaQueryListListener") {
    2661         $implIncludes{"MediaQueryListListener.h"} = 1;
     2668        AddToImplIncludes("MediaQueryListListener.h", $conditional);
    26622669        return "MediaQueryListListener::create(ScriptValue(exec->globalData(), " . $value ."))";
    26632670    }
    26642671
    26652672    if ($type eq "SerializedScriptValue" or $type eq "any") {
    2666         $implIncludes{"SerializedScriptValue.h"} = 1;
     2673        AddToImplIncludes("SerializedScriptValue.h", $conditional);
    26672674        return "SerializedScriptValue::create(exec, $value)";
    26682675    }
    26692676
    26702677    if ($type eq "IDBKey") {
    2671         $implIncludes{"IDBBindingUtilities.h"} = 1;
    2672         $implIncludes{"IDBKey.h"} = 1;
     2678        AddToImplIncludes("IDBBindingUtilities.h", $conditional);
     2679        AddToImplIncludes("IDBKey.h", $conditional);
    26732680        return "createIDBKeyFromValue(exec, $value)";
    26742681    }
    26752682
    2676     $implIncludes{"HTMLOptionElement.h"} = 1 if $type eq "HTMLOptionElement";
    2677     $implIncludes{"JSCustomVoidCallback.h"} = 1 if $type eq "VoidCallback";
    2678     $implIncludes{"Event.h"} = 1 if $type eq "Event";
     2683    AddToImplIncludes("HTMLOptionElement.h", $conditional) if $type eq "HTMLOptionElement";
     2684    AddToImplIncludes("JSCustomVoidCallback.h", $conditional) if $type eq "VoidCallback";
     2685    AddToImplIncludes("Event.h", $conditional) if $type eq "Event";
    26792686
    26802687    # Default, assume autogenerated type conversion routines
    2681     $implIncludes{"JS$type.h"} = 1;
     2688    AddToImplIncludes("JS$type.h", $conditional);
    26822689    return "to$type($value)";
    26832690}
     
    26912698    my $thisValue = shift;
    26922699
     2700    my $conditional = $signature->extendedAttributes->{"Conditional"};
    26932701    my $type = $codeGenerator->StripModule($signature->type);
    26942702
     
    27102718
    27112719    if ($codeGenerator->IsStringType($type)) {
    2712         $implIncludes{"KURL.h"} = 1;
     2720        AddToImplIncludes("KURL.h", $conditional);
    27132721        my $conv = $signature->extendedAttributes->{"ConvertNullStringTo"};
    27142722        if (defined $conv) {
     
    27212729        $conv = $signature->extendedAttributes->{"ConvertScriptString"};
    27222730        return "jsOwnedStringOrNull(exec, $value)" if $conv;
    2723         $implIncludes{"<runtime/JSString.h>"} = 1;
     2731        AddToImplIncludes("<runtime/JSString.h>", $conditional);
    27242732        return "jsString(exec, $value)";
    27252733    }
     
    27282736
    27292737    if ($type eq "CSSStyleDeclaration") {
    2730         $implIncludes{"CSSMutableStyleDeclaration.h"} = 1;
     2738        AddToImplIncludes("CSSMutableStyleDeclaration.h", $conditional);
    27312739    }
    27322740
    27332741    if ($type eq "NodeList") {
    2734         $implIncludes{"NameNodeList.h"} = 1;
     2742        AddToImplIncludes("NameNodeList.h", $conditional);
    27352743    }
    27362744
    27372745    if ($type eq "DOMObject") {
    27382746        if ($implClassName eq "Document") {
    2739             $implIncludes{"JSCanvasRenderingContext2D.h"} = 1;
     2747            AddToImplIncludes("JSCanvasRenderingContext2D.h", $conditional);
    27402748        } else {
    27412749            return "($value.hasNoValue() ? jsNull() : $value.jsValue())";
    27422750        }
    27432751    } elsif ($type =~ /SVGPathSeg/) {
    2744         $implIncludes{"JS$type.h"} = 1;
     2752        AddToImplIncludes("JS$type.h", $conditional);
    27452753        my $joinedName = $type;
    27462754        $joinedName =~ s/Abs|Rel//;
    2747         $implIncludes{"$joinedName.h"} = 1;
     2755        AddToImplIncludes("$joinedName.h", $conditional);
    27482756    } elsif ($type eq "SerializedScriptValue" or $type eq "any") {
    2749         $implIncludes{"SerializedScriptValue.h"} = 1;
     2757        AddToImplIncludes("SerializedScriptValue.h", $conditional);
    27502758        return "$value ? $value->deserialize(exec, castedThis->globalObject()) : jsNull()";
    27512759    } else {
    27522760        # Default, include header with same name.
    2753         $implIncludes{"JS$type.h"} = 1;
    2754         $implIncludes{"$type.h"} = 1 if not $codeGenerator->AvoidInclusionOfType($type);
     2761        AddToImplIncludes("JS$type.h", $conditional);
     2762        AddToImplIncludes("$type.h", $conditional) if not $codeGenerator->AvoidInclusionOfType($type);
    27552763    }
    27562764
     
    27752783            my $selfIsTearOffType = $codeGenerator->IsSVGTypeNeedingTearOff($implClassName);
    27762784            if ($selfIsTearOffType) {
    2777                 $implIncludes{"SVGStaticPropertyWithParentTearOff.h"} = 1;
     2785                AddToImplIncludes("SVGStaticPropertyWithParentTearOff.h", $conditional);
    27782786                $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyWithParentTearOff<$implClassName, /;
    27792787
     
    27862794                $value = "${tearOffType}::create(castedThis->impl(), $value, $updateMethod)";
    27872795            } else {
    2788                 $implIncludes{"SVGStaticPropertyTearOff.h"} = 1;
     2796                AddToImplIncludes("SVGStaticPropertyTearOff.h", $conditional);
    27892797                $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassName, /;
    27902798                $value = "${tearOffType}::create(imp, $value, $updateMethod)";
Note: See TracChangeset for help on using the changeset viewer.