Title: [152725] trunk
Revision
152725
Author
[email protected]
Date
2013-07-16 09:24:45 -0700 (Tue, 16 Jul 2013)

Log Message

Get rid of multiple inheritance support from the bindings generators
https://bugs.webkit.org/show_bug.cgi?id=118353

Reviewed by Kentaro Hara.

Source/WebCore:

Remove multiple inheritance support from the bindings generators (except
the ObjC one which still needs it for now). Multiple inheritance is no
longer supported in Web IDL and it makes the scripts more complex than
they needs to be.

Multiple inheritance support is no longer needed now that our SVG
interfaces have been updated to use the simpler SVG2 inheritance model
and use Web IDL 'implements' statements.

Note that the IDL parser still support multiple inheritance for now in
order not to break the ObjC bindings generator.

No new tests, no behavior change.

* bindings/scripts/CodeGenerator.pm:
* bindings/scripts/CodeGeneratorCPP.pm:
(GetParentImplClassName):
(GetParent):
(GenerateImplementation):
* bindings/scripts/CodeGeneratorGObject.pm:
(GetParentClassName):
(GetParentImplClassName):
(GetParentGObjType):
* bindings/scripts/CodeGeneratorJS.pm:
(GetParentClassName):
(GenerateHeader):
(GenerateImplementation):
(GenerateConstructorDefinition):
* bindings/scripts/CodeGeneratorObjC.pm:
(AddMethodsConstantsAndAttributesFromParentInterfaces):
(GenerateImplementation):
* bindings/scripts/IDLParser.pm:
(parseInterface):
(parseException):
(parseInheritance):

Tools:

Update CodeGeneratorTestRunner.pm to use domInterface->parent instead of
deprecated domInterface->parents.

* WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
(_parentInterface):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (152724 => 152725)


--- trunk/Source/WebCore/ChangeLog	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Source/WebCore/ChangeLog	2013-07-16 16:24:45 UTC (rev 152725)
@@ -1,3 +1,46 @@
+2013-07-16  Christophe Dumez  <[email protected]>
+
+        Get rid of multiple inheritance support from the bindings generators
+        https://bugs.webkit.org/show_bug.cgi?id=118353
+
+        Reviewed by Kentaro Hara.
+
+        Remove multiple inheritance support from the bindings generators (except
+        the ObjC one which still needs it for now). Multiple inheritance is no
+        longer supported in Web IDL and it makes the scripts more complex than
+        they needs to be.
+
+        Multiple inheritance support is no longer needed now that our SVG
+        interfaces have been updated to use the simpler SVG2 inheritance model
+        and use Web IDL 'implements' statements.
+
+        Note that the IDL parser still support multiple inheritance for now in
+        order not to break the ObjC bindings generator.
+
+        No new tests, no behavior change.
+
+        * bindings/scripts/CodeGenerator.pm:
+        * bindings/scripts/CodeGeneratorCPP.pm:
+        (GetParentImplClassName):
+        (GetParent):
+        (GenerateImplementation):
+        * bindings/scripts/CodeGeneratorGObject.pm:
+        (GetParentClassName):
+        (GetParentImplClassName):
+        (GetParentGObjType):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GetParentClassName):
+        (GenerateHeader):
+        (GenerateImplementation):
+        (GenerateConstructorDefinition):
+        * bindings/scripts/CodeGeneratorObjC.pm:
+        (AddMethodsConstantsAndAttributesFromParentInterfaces):
+        (GenerateImplementation):
+        * bindings/scripts/IDLParser.pm:
+        (parseInterface):
+        (parseException):
+        (parseInheritance):
+
 2013-07-16  Eric Carlson  <[email protected]>
 
         HTMLMediaElement should not add cues for disabled text tracks

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (152724 => 152725)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2013-07-16 16:24:45 UTC (rev 152725)
@@ -205,58 +205,6 @@
     &$recurse($interface);
 }
 
-sub AddMethodsConstantsAndAttributesFromParentInterfaces
-{
-    # Add to $interface all of its inherited interface members, except for those
-    # inherited through $interface's first listed parent.  If an array reference
-    # is passed in as $parents, the names of all ancestor interfaces visited
-    # will be appended to the array.  If $collectDirectParents is true, then
-    # even the names of $interface's first listed parent and its ancestors will
-    # be appended to $parents.
-
-    my $object = shift;
-    my $interface = shift;
-    my $parents = shift;
-    my $collectDirectParents = shift;
-
-    my $first = 1;
-
-    $object->ForAllParents($interface, sub {
-        my $currentInterface = shift;
-
-        if ($first) {
-            # Ignore first parent class, already handled by the generation itself.
-            $first = 0;
-
-            if ($collectDirectParents) {
-                # Just collect the names of the direct ancestor interfaces,
-                # if necessary.
-                push(@$parents, $currentInterface->name);
-                $object->ForAllParents($currentInterface, sub {
-                    my $currentInterface = shift;
-                    push(@$parents, $currentInterface->name);
-                }, undef);
-            }
-
-            # Prune the recursion here.
-            return 'prune';
-        }
-
-        # Collect the name of this additional parent.
-        push(@$parents, $currentInterface->name) if $parents;
-
-        print "  |  |>  -> Inheriting "
-            . @{$currentInterface->constants} . " constants, "
-            . @{$currentInterface->functions} . " functions, "
-            . @{$currentInterface->attributes} . " attributes...\n  |  |>\n" if $verbose;
-
-        # Add this parent's members to $interface.
-        push(@{$interface->constants}, @{$currentInterface->constants});
-        push(@{$interface->functions}, @{$currentInterface->functions});
-        push(@{$interface->attributes}, @{$currentInterface->attributes});
-    });
-}
-
 sub FindSuperMethod
 {
     my ($object, $interface, $functionName) = @_;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm (152724 => 152725)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm	2013-07-16 16:24:45 UTC (rev 152725)
@@ -139,30 +139,25 @@
 {
     my $interface = shift;
 
-    if (@{$interface->parents} eq 0) {
+    unless ($interface->parent) {
         return "EventTarget" if $interface->extendedAttributes->{"EventTarget"};
         return "Object";
     }
 
-    return $interface->parents(0);
+    return $interface->parent;
 }
 
 sub GetParent
 {
     my $interface = shift;
-    my $numParents = @{$interface->parents};
 
-    my $parent = "";
-    if ($numParents eq 0) {
+    my $parent;
+    if (!$interface->parent) {
         $parent = "WebDOMObject";
         $parent = "WebDOMEventTarget" if $interface->extendedAttributes->{"EventTarget"};
-    } elsif ($numParents eq 1) {
-        my $parentName = $interface->parents(0);
-        $parent = "WebDOM" . $parentName;
     } else {
-        my @parents = @{$interface->parents};
-        my $firstParent = shift(@parents);
-        $parent = "WebDOM" . $firstParent;
+        my $parentName = $interface->parent;
+        $parent = "WebDOM" . $parentName;
     }
 
     return $parent;
@@ -591,12 +586,6 @@
     my $object = shift;
     my $interface = shift;
 
-    my @ancestorInterfaceNames = ();
-
-    if (@{$interface->parents} > 1) {
-        $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@ancestorInterfaceNames);
-    }
-
     my $interfaceName = $interface->name;
     my $className = GetClassName($interfaceName);
     my $implClassName = GetImplClassName($interfaceName);

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm (152724 => 152725)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm	2013-07-16 16:24:45 UTC (rev 152725)
@@ -87,15 +87,15 @@
 sub GetParentClassName {
     my $interface = shift;
 
-    return "WebKitDOMObject" if @{$interface->parents} eq 0;
-    return "WebKitDOM" . $interface->parents(0);
+    return "WebKitDOMObject" unless $interface->parent;
+    return "WebKitDOM" . $interface->parent;
 }
 
 sub GetParentImplClassName {
     my $interface = shift;
 
-    return "Object" if @{$interface->parents} eq 0;
-    return $interface->parents(0);
+    return "Object" unless $interface->parent;
+    return $interface->parent;
 }
 
 sub IsBaseType
@@ -183,8 +183,8 @@
 sub GetParentGObjType {
     my $interface = shift;
 
-    return "WEBKIT_TYPE_DOM_OBJECT" if @{$interface->parents} eq 0;
-    return "WEBKIT_TYPE_DOM_" . ClassNameToGObjectType($interface->parents(0));
+    return "WEBKIT_TYPE_DOM_OBJECT" unless $interface->parent;
+    return "WEBKIT_TYPE_DOM_" . ClassNameToGObjectType($interface->parent);
 }
 
 sub GetClassName {

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (152724 => 152725)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2013-07-16 16:24:45 UTC (rev 152725)
@@ -167,8 +167,8 @@
     my $interface = shift;
 
     return $interface->extendedAttributes->{"JSLegacyParent"} if $interface->extendedAttributes->{"JSLegacyParent"};
-    return "JSDOMWrapper" if (@{$interface->parents} eq 0);
-    return "JS" . $interface->parents(0);
+    return "JSDOMWrapper" unless $interface->parent;
+    return "JS" . $interface->parent;
 }
 
 sub GetCallbackClassName
@@ -650,17 +650,10 @@
 
     my $interfaceName = $interface->name;
     my $className = "JS$interfaceName";
-    my @ancestorInterfaceNames = ();
     my %structureFlags = ();
 
-    # We only support multiple parents with SVG (for now).
-    if (@{$interface->parents} > 1) {
-        die "A class can't have more than one parent" unless $interfaceName =~ /SVG/;
-        $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@ancestorInterfaceNames);
-    }
-
     my $hasLegacyParent = $interface->extendedAttributes->{"JSLegacyParent"};
-    my $hasRealParent = @{$interface->parents} > 0;
+    my $hasRealParent = $interface->parent;
     my $hasParent = $hasLegacyParent || $hasRealParent;
     my $parentClassName = GetParentClassName($interface);
     my $needsMarkChildren = $interface->extendedAttributes->{"JSCustomMarkFunction"} || $interface->extendedAttributes->{"EventTarget"} || $interface->name eq "EventTarget";
@@ -1194,12 +1187,6 @@
     push(@headerContent, "\n} // namespace WebCore\n\n");
     push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString;
     push(@headerContent, "#endif\n");
-
-    # - Generate dependencies.
-    if ($writeDependencies && @ancestorInterfaceNames) {
-        push(@depsContent, "$className.h : ", join(" ", map { "$_.idl" } @ancestorInterfaceNames), "\n");
-        push(@depsContent, map { "$_.idl :\n" } @ancestorInterfaceNames); 
-    }
 }
 
 sub GenerateAttributesHashTable($$)
@@ -1584,7 +1571,7 @@
     my $className = "JS$interfaceName";
 
     my $hasLegacyParent = $interface->extendedAttributes->{"JSLegacyParent"};
-    my $hasRealParent = @{$interface->parents} > 0;
+    my $hasRealParent = $interface->parent;
     my $hasParent = $hasLegacyParent || $hasRealParent;
     my $parentClassName = GetParentClassName($interface);
     my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
@@ -4091,7 +4078,8 @@
 {
 END
 
-            foreach my $interfaceBase (@{$interface->parents}) {
+            if ($interface->parent) {
+                my $interfaceBase = $interface->parent;
                 push(@implContent, <<END);
     if (!fill${interfaceBase}Init(eventInit, dictionary))
         return false;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm (152724 => 152725)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm	2013-07-16 16:24:45 UTC (rev 152725)
@@ -266,6 +266,57 @@
     $interfaceAvailabilityVersion = "WEBKIT_VERSION_LATEST" if $newPublicClass;
 }
 
+sub AddMethodsConstantsAndAttributesFromParentInterfaces
+{
+    # Add to $interface all of its inherited interface members, except for those
+    # inherited through $interface's first listed parent.  If an array reference
+    # is passed in as $parents, the names of all ancestor interfaces visited
+    # will be appended to the array.  If $collectDirectParents is true, then
+    # even the names of $interface's first listed parent and its ancestors will
+    # be appended to $parents.
+
+    my $interface = shift;
+    my $parents = shift;
+    my $collectDirectParents = shift;
+
+    my $first = 1;
+
+    $codeGenerator->ForAllParents($interface, sub {
+        my $currentInterface = shift;
+
+        if ($first) {
+            # Ignore first parent class, already handled by the generation itself.
+            $first = 0;
+
+            if ($collectDirectParents) {
+                # Just collect the names of the direct ancestor interfaces,
+                # if necessary.
+                push(@$parents, $currentInterface->name);
+                $codeGenerator->ForAllParents($currentInterface, sub {
+                    my $currentInterface = shift;
+                    push(@$parents, $currentInterface->name);
+                }, undef);
+            }
+
+            # Prune the recursion here.
+            return 'prune';
+        }
+
+        # Collect the name of this additional parent.
+        push(@$parents, $currentInterface->name) if $parents;
+
+        print "  |  |>  -> Inheriting "
+            . @{$currentInterface->constants} . " constants, "
+            . @{$currentInterface->functions} . " functions, "
+            . @{$currentInterface->attributes} . " attributes...\n  |  |>\n" if $verbose;
+
+        # Add this parent's members to $interface.
+        push(@{$interface->constants}, @{$currentInterface->constants});
+        push(@{$interface->functions}, @{$currentInterface->functions});
+        push(@{$interface->attributes}, @{$currentInterface->attributes});
+    });
+}
+
 sub GenerateInterface
 {
     my $object = shift;
@@ -1048,7 +1099,7 @@
     my @ancestorInterfaceNames = ();
 
     if (@{$interface->parents} > 1) {
-        $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@ancestorInterfaceNames);
+        AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@ancestorInterfaceNames);
     }
 
     my $interfaceName = $interface->name;

Modified: trunk/Source/WebCore/bindings/scripts/IDLParser.pm (152724 => 152725)


--- trunk/Source/WebCore/bindings/scripts/IDLParser.pm	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Source/WebCore/bindings/scripts/IDLParser.pm	2013-07-16 16:24:45 UTC (rev 152725)
@@ -43,7 +43,8 @@
 # Used to represent 'interface' blocks
 struct( domInterface => {
     name => '$',      # Class identifier
-    parents => '@',      # List of strings
+    parent => '$',      # Parent class identifier
+    parents => '@',      # Parent class identifiers (Kept for compatibility with ObjC bindings)
     constants => '@',    # List of 'domConstant'
     functions => '@',    # List of 'domFunction'
     anonymousFunctions => '@', # List of 'domFunction'
@@ -496,7 +497,9 @@
         my $interfaceNameToken = $self->getToken();
         $self->assertTokenType($interfaceNameToken, IdentifierToken);
         $interface->name($interfaceNameToken->value());
-        push(@{$interface->parents}, @{$self->parseInheritance()});
+        my $parents = $self->parseInheritance();
+        $interface->parents($parents);
+        $interface->parent($parents->[0]);
         $self->assertTokenValue($self->getToken(), "{", __LINE__);
         my $interfaceMembers = $self->parseInterfaceMembers();
         $self->assertTokenValue($self->getToken(), "}", __LINE__);
@@ -695,7 +698,9 @@
         $self->assertTokenType($exceptionNameToken, IdentifierToken);
         $interface->name($exceptionNameToken->value());
         $interface->isException(1);
-        push(@{$interface->parents}, @{$self->parseInheritance()});
+        my $parents = $self->parseInheritance();
+        $interface->parents($parents);
+        $interface->parent($parents->[0]);
         $self->assertTokenValue($self->getToken(), "{", __LINE__);
         my $exceptionMembers = $self->parseExceptionMembers();
         $self->assertTokenValue($self->getToken(), "}", __LINE__);
@@ -738,7 +743,7 @@
         $self->assertTokenValue($self->getToken(), ":", __LINE__);
         my $scopedName = $self->parseScopedName();
         push(@parent, $scopedName);
-        # Multiple inheritance?
+        # Multiple inheritance (needed for ObjC bindings).
         push(@parent, @{$self->parseIdentifiers()});
     }
     return \@parent;

Modified: trunk/Tools/ChangeLog (152724 => 152725)


--- trunk/Tools/ChangeLog	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Tools/ChangeLog	2013-07-16 16:24:45 UTC (rev 152725)
@@ -1,3 +1,16 @@
+2013-07-16  Christophe Dumez  <[email protected]>
+
+        Get rid of multiple inheritance support from the bindings generators
+        https://bugs.webkit.org/show_bug.cgi?id=118353
+
+        Reviewed by Kentaro Hara.
+
+        Update CodeGeneratorTestRunner.pm to use domInterface->parent instead of
+        deprecated domInterface->parents.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
+        (_parentInterface):
+
 2013-07-16  Brian Holt  <[email protected]>
 
         check-webkit-style: "using namespace foo;" should be flagged as an error in headers

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm (152724 => 152725)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm	2013-07-16 16:24:04 UTC (rev 152724)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm	2013-07-16 16:24:45 UTC (rev 152725)
@@ -416,7 +416,7 @@
 sub _parentInterface
 {
     my ($interface) = @_;
-    return $interface->parents->[0];
+    return $interface->parent;
 }
 
 sub _platformType
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to