Changeset 140303 in webkit


Ignore:
Timestamp:
Jan 20, 2013 11:27:56 PM (11 years ago)
Author:
haraken@chromium.org
Message:

Add a [ConstructorConditional] IDL attribute
https://bugs.webkit.org/show_bug.cgi?id=107407

Reviewed by Adam Barth.

Per discussion in webkit-dev, we need to implement DOM4 event constructors
under a enable flag. For that purpose, we implement a [ConstructorConditional]
IDL attribute.

Test: bindings/scripts/test/TestInterface.idl

  • bindings/scripts/CodeGenerator.pm:

(GenerateConstructorConditionalString):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateConstructorDeclaration):
(GenerateConstructorHelperMethods):

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateHeader):
(GenerateImplementation):

  • bindings/scripts/IDLAttributes.txt:
  • bindings/scripts/test/JS/JSTestInterface.cpp:

(WebCore):

  • bindings/scripts/test/JS/JSTestInterface.h:

(JSTestInterfaceConstructor):

  • bindings/scripts/test/TestInterface.idl:
  • bindings/scripts/test/V8/V8TestInterface.cpp:

(WebCore::ConfigureV8TestInterfaceTemplate):

  • bindings/scripts/test/V8/V8TestInterface.h:

(V8TestInterface):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140302 r140303  
     12013-01-20  Kentaro Hara  <haraken@chromium.org>
     2
     3        Add a [ConstructorConditional] IDL attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=107407
     5
     6        Reviewed by Adam Barth.
     7
     8        Per discussion in webkit-dev, we need to implement DOM4 event constructors
     9        under a enable flag. For that purpose, we implement a [ConstructorConditional]
     10        IDL attribute.
     11
     12        Test: bindings/scripts/test/TestInterface.idl
     13
     14        * bindings/scripts/CodeGenerator.pm:
     15        (GenerateConstructorConditionalString):
     16        * bindings/scripts/CodeGeneratorJS.pm:
     17        (GenerateConstructorDeclaration):
     18        (GenerateConstructorHelperMethods):
     19        * bindings/scripts/CodeGeneratorV8.pm:
     20        (GenerateHeader):
     21        (GenerateImplementation):
     22        * bindings/scripts/IDLAttributes.txt:
     23        * bindings/scripts/test/JS/JSTestInterface.cpp:
     24        (WebCore):
     25        * bindings/scripts/test/JS/JSTestInterface.h:
     26        (JSTestInterfaceConstructor):
     27        * bindings/scripts/test/TestInterface.idl:
     28        * bindings/scripts/test/V8/V8TestInterface.cpp:
     29        (WebCore::ConfigureV8TestInterfaceTemplate):
     30        * bindings/scripts/test/V8/V8TestInterface.h:
     31        (V8TestInterface):
     32
    1332013-01-20  Kentaro Hara  <haraken@chromium.org>
    234
  • trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm

    r139641 r140303  
    649649}
    650650
     651sub GenerateConstructorConditionalString
     652{
     653    my $generator = shift;
     654    my $node = shift;
     655
     656    my $conditional = $node->extendedAttributes->{"ConstructorConditional"};
     657    if ($conditional) {
     658        return $generator->GenerateConditionalStringFromAttributeValue($conditional);
     659    } else {
     660        return "";
     661    }
     662}
     663
    651664sub GenerateConditionalStringFromAttributeValue
    652665{
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r140182 r140303  
    36833683        }
    36843684
     3685        my $conditionalString = $codeGenerator->GenerateConstructorConditionalString($interface);
     3686        push(@$outputArray, "#if $conditionalString\n") if $conditionalString;
    36853687        push(@$outputArray, "    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);\n");
     3688        push(@$outputArray, "#endif // $conditionalString\n") if $conditionalString;
    36863689    }
    36873690    push(@$outputArray, "};\n\n");
     
    40514054    if (IsConstructable($interface)) {
    40524055        if (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor) {
     4056            my $conditionalString = $codeGenerator->GenerateConstructorConditionalString($interface);
     4057            push(@$outputArray, "#if $conditionalString\n") if $conditionalString;
    40534058            push(@$outputArray, "ConstructType ${constructorClassName}::getConstructData(JSCell*, ConstructData& constructData)\n");
    40544059            push(@$outputArray, "{\n");
    40554060            push(@$outputArray, "    constructData.native.function = construct${className};\n");
    40564061            push(@$outputArray, "    return ConstructTypeHost;\n");
    4057             push(@$outputArray, "}\n\n");
     4062            push(@$outputArray, "}\n");
     4063            push(@$outputArray, "#endif // $conditionalString\n") if $conditionalString;
     4064            push(@$outputArray, "\n");
    40584065        }
    40594066    }
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r139900 r140303  
    406406
    407407    if (IsConstructable($interface)) {
    408         push(@headerContent, <<END);
    409     static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
     408        my $conditionalString = $codeGenerator->GenerateConstructorConditionalString($interface);
     409        push(@headerContent, "#if $conditionalString\n") if $conditionalString;
     410        push(@headerContent, "    static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);\n");
     411        push(@headerContent, "#endif // $conditionalString\n") if $conditionalString;
    410412END
    411413    }
     
    29492951
    29502952    if (IsConstructable($interface)) {
    2951         push(@implContent, <<END);
    2952     desc->SetCallHandler(${v8InterfaceName}::constructorCallback);
    2953 END
     2953        my $conditionalString = $codeGenerator->GenerateConstructorConditionalString($interface);
     2954        push(@implContent, "#if $conditionalString\n") if $conditionalString;
     2955        push(@implContent, "    desc->SetCallHandler(${v8InterfaceName}::constructorCallback);\n");
     2956        push(@implContent, "#endif // $conditionalString\n") if $conditionalString;
    29542957    }
    29552958
  • trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt

    r139331 r140303  
    2929Conditional=*
    3030Constructor
     31ConstructorConditional=*
    3132ConstructorParameters=*
    3233ConstructorRaisesException
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r138008 r140303  
    149149}
    150150
     151#if ENABLE(TEST_INTERFACE)
    151152ConstructType JSTestInterfaceConstructor::getConstructData(JSCell*, ConstructData& constructData)
    152153{
     
    154155    return ConstructTypeHost;
    155156}
     157#endif // ENABLE(TEST_INTERFACE)
    156158
    157159/* Hash table for prototype */
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h

    r135081 r140303  
    153153    static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
    154154    static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestInterface(JSC::ExecState*);
     155#if ENABLE(TEST_INTERFACE)
    155156    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
     157#endif // ENABLE(TEST_INTERFACE)
    156158};
    157159
  • trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl

    r131172 r140303  
    3535    CallWith=ScriptExecutionContext,
    3636    Constructor(in DOMString str1, in [Optional=DefaultIsUndefined] DOMString str2),
    37     ConstructorRaisesException
     37    ConstructorRaisesException,
     38    ConstructorConditional=TEST_INTERFACE
    3839] interface TestInterface {
    3940};
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp

    r139483 r140303  
    266266        V8TestInterfaceCallbacks, WTF_ARRAY_LENGTH(V8TestInterfaceCallbacks));
    267267    UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
     268#if ENABLE(TEST_INTERFACE)
    268269    desc->SetCallHandler(V8TestInterface::constructorCallback);
     270#endif // ENABLE(TEST_INTERFACE)
    269271    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
    270272    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h

    r139900 r140303  
    4747    static WrapperTypeInfo info;
    4848    static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
     49#if ENABLE(TEST_INTERFACE)
    4950    static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
     51#endif // ENABLE(TEST_INTERFACE)
    5052    static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo&);
    5153    static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0;
Note: See TracChangeset for help on using the changeset viewer.