Changeset 207770 in webkit


Ignore:
Timestamp:
Oct 24, 2016 11:29:36 AM (7 years ago)
Author:
zandobersek@gmail.com
Message:

[CodeGenerator] Only allow a single interface or standalone dictionary per WebIDL file
https://bugs.webkit.org/show_bug.cgi?id=163889

Reviewed by Chris Dumez.

Assert that there's only one interface or standalone dictionary
per WebIDL input file, and exit from the generator otherwise.

This avoids potential linking issues where multiple enumeration
and dictionary bindings code can be generated if the source
WebIDL for them is specified in a file that contains multiple
interfaces or standalone dictionaries.

Additionally, the generator now also exits if it fails to
generate code for any interface of standalone dictionary. This
should avoid processing WebIDL files that are empty in
substance.

TestException.idl and TestInterface.idl files have their second
interfaces removed. In place of those a new testing IDL file is
added, TestInterfaceLeadingUnderscore.idl. Like the two removed
interfaces, it tests that the leading underscode in the
identifier is removed by the generator.

  • bindings/scripts/CodeGenerator.pm:

(ProcessDocument):

  • bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.cpp: Added.

(WebCore::JSTestInterfaceLeadingUnderscorePrototype::create):
(WebCore::JSTestInterfaceLeadingUnderscorePrototype::createStructure):
(WebCore::JSTestInterfaceLeadingUnderscorePrototype::JSTestInterfaceLeadingUnderscorePrototype):
(WebCore::JSTestInterfaceLeadingUnderscoreConstructor::prototypeForStructure):
(WebCore::JSTestInterfaceLeadingUnderscoreConstructor::initializeProperties):
(WebCore::JSTestInterfaceLeadingUnderscorePrototype::finishCreation):
(WebCore::JSTestInterfaceLeadingUnderscore::JSTestInterfaceLeadingUnderscore):
(WebCore::JSTestInterfaceLeadingUnderscore::createPrototype):
(WebCore::JSTestInterfaceLeadingUnderscore::prototype):
(WebCore::JSTestInterfaceLeadingUnderscore::destroy):
(WebCore::BindingCaller<JSTestInterfaceLeadingUnderscore>::castForAttribute):
(WebCore::jsTestInterfaceLeadingUnderscoreReadonly):
(WebCore::jsTestInterfaceLeadingUnderscoreReadonlyGetter):
(WebCore::jsTestInterfaceLeadingUnderscoreConstructor):
(WebCore::setJSTestInterfaceLeadingUnderscoreConstructor):
(WebCore::JSTestInterfaceLeadingUnderscore::getConstructor):
(WebCore::JSTestInterfaceLeadingUnderscoreOwner::isReachableFromOpaqueRoots):
(WebCore::JSTestInterfaceLeadingUnderscoreOwner::finalize):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
(WebCore::JSTestInterfaceLeadingUnderscore::toWrapped):

  • bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.h: Renamed from Source/WebCore/bindings/scripts/test/JS/JSreadonly.h.

(WebCore::JSTestInterfaceLeadingUnderscore::create):
(WebCore::JSTestInterfaceLeadingUnderscore::createStructure):
(WebCore::JSTestInterfaceLeadingUnderscore::finishCreation):
(WebCore::wrapperOwner):
(WebCore::wrapperKey):
(WebCore::toJS):
(WebCore::toJSNewlyCreated):

  • bindings/scripts/test/JS/JSattribute.cpp: Removed.
  • bindings/scripts/test/JS/JSattribute.h: Removed.
  • bindings/scripts/test/JS/JSreadonly.cpp: Removed.
  • bindings/scripts/test/TestException.idl:
  • bindings/scripts/test/TestInterface.idl:
  • bindings/scripts/test/TestInterfaceLeadingUnderscore.idl: Copied from Source/WebCore/bindings/scripts/test/TestException.idl.
Location:
trunk/Source/WebCore
Files:
3 added
4 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207769 r207770  
     12016-10-24  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [CodeGenerator] Only allow a single interface or standalone dictionary per WebIDL file
     4        https://bugs.webkit.org/show_bug.cgi?id=163889
     5
     6        Reviewed by Chris Dumez.
     7
     8        Assert that there's only one interface or standalone dictionary
     9        per WebIDL input file, and exit from the generator otherwise.
     10
     11        This avoids potential linking issues where multiple enumeration
     12        and dictionary bindings code can be generated if the source
     13        WebIDL for them is specified in a file that contains multiple
     14        interfaces or standalone dictionaries.
     15
     16        Additionally, the generator now also exits if it fails to
     17        generate code for any interface of standalone dictionary. This
     18        should avoid processing WebIDL files that are empty in
     19        substance.
     20
     21        TestException.idl and TestInterface.idl files have their second
     22        interfaces removed. In place of those a new testing IDL file is
     23        added, TestInterfaceLeadingUnderscore.idl. Like the two removed
     24        interfaces, it tests that the leading underscode in the
     25        identifier is removed by the generator.
     26
     27        * bindings/scripts/CodeGenerator.pm:
     28        (ProcessDocument):
     29        * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.cpp: Added.
     30        (WebCore::JSTestInterfaceLeadingUnderscorePrototype::create):
     31        (WebCore::JSTestInterfaceLeadingUnderscorePrototype::createStructure):
     32        (WebCore::JSTestInterfaceLeadingUnderscorePrototype::JSTestInterfaceLeadingUnderscorePrototype):
     33        (WebCore::JSTestInterfaceLeadingUnderscoreConstructor::prototypeForStructure):
     34        (WebCore::JSTestInterfaceLeadingUnderscoreConstructor::initializeProperties):
     35        (WebCore::JSTestInterfaceLeadingUnderscorePrototype::finishCreation):
     36        (WebCore::JSTestInterfaceLeadingUnderscore::JSTestInterfaceLeadingUnderscore):
     37        (WebCore::JSTestInterfaceLeadingUnderscore::createPrototype):
     38        (WebCore::JSTestInterfaceLeadingUnderscore::prototype):
     39        (WebCore::JSTestInterfaceLeadingUnderscore::destroy):
     40        (WebCore::BindingCaller<JSTestInterfaceLeadingUnderscore>::castForAttribute):
     41        (WebCore::jsTestInterfaceLeadingUnderscoreReadonly):
     42        (WebCore::jsTestInterfaceLeadingUnderscoreReadonlyGetter):
     43        (WebCore::jsTestInterfaceLeadingUnderscoreConstructor):
     44        (WebCore::setJSTestInterfaceLeadingUnderscoreConstructor):
     45        (WebCore::JSTestInterfaceLeadingUnderscore::getConstructor):
     46        (WebCore::JSTestInterfaceLeadingUnderscoreOwner::isReachableFromOpaqueRoots):
     47        (WebCore::JSTestInterfaceLeadingUnderscoreOwner::finalize):
     48        (WebCore::toJSNewlyCreated):
     49        (WebCore::toJS):
     50        (WebCore::JSTestInterfaceLeadingUnderscore::toWrapped):
     51        * bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.h: Renamed from Source/WebCore/bindings/scripts/test/JS/JSreadonly.h.
     52        (WebCore::JSTestInterfaceLeadingUnderscore::create):
     53        (WebCore::JSTestInterfaceLeadingUnderscore::createStructure):
     54        (WebCore::JSTestInterfaceLeadingUnderscore::finishCreation):
     55        (WebCore::wrapperOwner):
     56        (WebCore::wrapperKey):
     57        (WebCore::toJS):
     58        (WebCore::toJSNewlyCreated):
     59        * bindings/scripts/test/JS/JSattribute.cpp: Removed.
     60        * bindings/scripts/test/JS/JSattribute.h: Removed.
     61        * bindings/scripts/test/JS/JSreadonly.cpp: Removed.
     62        * bindings/scripts/test/TestException.idl:
     63        * bindings/scripts/test/TestInterface.idl:
     64        * bindings/scripts/test/TestInterfaceLeadingUnderscore.idl: Copied from Source/WebCore/bindings/scripts/test/TestException.idl.
     65
    1662016-10-21  Alex Christensen  <achristensen@webkit.org>
    267
  • trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm

    r207768 r207770  
    206206
    207207    my $interfaces = $useDocument->interfaces;
    208     foreach my $interface (@$interfaces) {
     208    if (@$interfaces) {
     209        die "Multiple interfaces per document are not supported" if @$interfaces > 1;
     210
     211        my $interface = @$interfaces[0];
    209212        print "Generating $useGenerator bindings code for IDL interface \"" . $interface->name . "\"...\n" if $verbose;
    210         # FIXME: Repeating each enumeration and dictionaries for every interface would not work if we actually were using
    211         # multiple interfaces per file, but we aren't, so this is fine for now.
    212213        $codeGenerator->GenerateInterface($interface, $defines, $useDocument->enumerations, $useDocument->dictionaries);
    213214        $codeGenerator->WriteData($interface, $useOutputDir, $useOutputHeadersDir);
    214     }
    215 
    216     # It is possible to have dictionaries in an IDL file without any interface.
    217     unless (@$interfaces) {
    218         foreach my $dictionary (@{$useDocument->dictionaries}) {
    219             $codeGenerator->GenerateDictionary($dictionary, $useDocument->enumerations);
    220             $codeGenerator->WriteData($dictionary, $useOutputDir, $useOutputHeadersDir);
    221         }
    222     }
     215        return;
     216    }
     217
     218    my $dictionaries = $useDocument->dictionaries;
     219    if (@$dictionaries) {
     220        die "Multiple standalone dictionaries per document are not supported" if @$dictionaries > 1;
     221
     222        my $dictionary = @$dictionaries[0];
     223        print "Generating $useGenerator bindings code for IDL dictionary \"" . $dictionary->name . "\"...\n" if $verbose;
     224        $codeGenerator->GenerateDictionary($dictionary, $useDocument->enumerations);
     225        $codeGenerator->WriteData($dictionary, $useOutputDir, $useOutputHeadersDir);
     226        return;
     227    }
     228
     229    die "Processing document " . $useDocument->fileName . " did not generate anything"
    223230}
    224231
  • trunk/Source/WebCore/bindings/scripts/test/TestException.idl

    r165676 r207770  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829exception TestException {
    2930   readonly attribute DOMString name;
    3031};
    31 
    32 // Identifiers with a leading underscore, which should be removed.
    33 exception _attribute {
    34    readonly attribute DOMString _readonly;
    35 };
  • trunk/Source/WebCore/bindings/scripts/test/TestInterface.idl

    r207279 r207770  
    4242
    4343TestInterface implements TestImplements;
    44 
    45 [
    46     ImplementationLacksVTable
    47 ] interface _readonly {
    48 };
Note: See TracChangeset for help on using the changeset viewer.