Title: [207278] trunk/Source/WebCore
Revision
207278
Author
cdu...@apple.com
Date
2016-10-12 22:21:14 -0700 (Wed, 12 Oct 2016)

Log Message

The bindings generator should provide a better error message when it does not find a dictionary definition
https://bugs.webkit.org/show_bug.cgi?id=163377

Reviewed by Ryosuke Niwa.

The bindings generator should provide a better error message when it does
not find a dictionary definition.

* bindings/scripts/CodeGenerator.pm:
(GetDictionaryByName):
* bindings/scripts/CodeGeneratorJS.pm:
(assert):
(GenerateDictionaryImplementationContent):
(GenerateHeader):
(GenerateDictionaryHeader):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207277 => 207278)


--- trunk/Source/WebCore/ChangeLog	2016-10-13 05:18:59 UTC (rev 207277)
+++ trunk/Source/WebCore/ChangeLog	2016-10-13 05:21:14 UTC (rev 207278)
@@ -1,5 +1,23 @@
 2016-10-12  Chris Dumez  <cdu...@apple.com>
 
+        The bindings generator should provide a better error message when it does not find a dictionary definition
+        https://bugs.webkit.org/show_bug.cgi?id=163377
+
+        Reviewed by Ryosuke Niwa.
+
+        The bindings generator should provide a better error message when it does
+        not find a dictionary definition.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (GetDictionaryByName):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (assert):
+        (GenerateDictionaryImplementationContent):
+        (GenerateHeader):
+        (GenerateDictionaryHeader):
+
+2016-10-12  Chris Dumez  <cdu...@apple.com>
+
         Update WebKitMediaKeyMessageEvent / WebKitMediaKeyNeededEvent to stop using legacy [ConstructorTemplate=Event]
         https://bugs.webkit.org/show_bug.cgi?id=163369
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (207277 => 207278)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2016-10-13 05:18:59 UTC (rev 207277)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2016-10-13 05:21:14 UTC (rev 207278)
@@ -474,7 +474,7 @@
 sub GetDictionaryByName
 {
     my ($object, $name) = @_;
-    return unless defined($name);
+    die "GetDictionaryByName() was called with an undefined dictionary name" unless defined($name);
 
     for my $dictionary (@{$useDocument->dictionaries}) {
         return $dictionary if $dictionary->name eq $name;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (207277 => 207278)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-13 05:18:59 UTC (rev 207277)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-13 05:21:14 UTC (rev 207278)
@@ -33,6 +33,8 @@
 
 use strict;
 use constant FileNamePrefix => "JS";
+use Carp qw<longmess>;
+use Data::Dumper;
 use Hasher;
 
 my $codeGenerator;
@@ -107,6 +109,16 @@
 */
 EOF
 
+sub assert
+{
+    my $message = shift;
+
+    my $mess = longmess();
+    print Dumper($mess);
+
+    die $message;
+}
+
 # Default constructor
 sub new
 {
@@ -1092,10 +1104,12 @@
     # 4. Let dictionaries be a list consisting of D and all of D’s inherited dictionaries, in order from least to most derived.
     my @dictionaries;
     push(@dictionaries, $dictionary);
-    my $parentDictionary = $codeGenerator->GetDictionaryByName($dictionary->parent);
-    while (defined($parentDictionary)) {
+    my $parentName = $dictionary->parent;
+    while (defined($parentName)) {
+        my $parentDictionary = $codeGenerator->GetDictionaryByName($parentName);
+        assert("Unable to find definition for dictionary named '" . $parentName . "'!") unless defined($parentDictionary);
         unshift(@dictionaries, $parentDictionary);
-        $parentDictionary = $codeGenerator->GetDictionaryByName($parentDictionary->parent);
+        $parentName = $parentDictionary->parent;
     }
 
     my $arguments = "";
@@ -1741,10 +1755,12 @@
             push(@ancestors, $currentInterface->name);
         }, 0);
         for my $dictionary (@$dictionaries) {
-            my $parentDictionary = $dictionary->parent;
-            while (defined($parentDictionary)) {
-                push(@ancestors, $parentDictionary) if $codeGenerator->IsExternalDictionaryType($parentDictionary);
-                $parentDictionary = $codeGenerator->GetDictionaryByName($parentDictionary)->parent;
+            my $parentName = $dictionary->parent;
+            while (defined($parentName)) {
+                push(@ancestors, $parentName) if $codeGenerator->IsExternalDictionaryType($parentName);
+                my $parentDictionary = $codeGenerator->GetDictionaryByName($parentName);
+                assert("Unable to find definition for dictionary named '" . $parentName . "'!") unless defined($parentDictionary);
+                $parentName = $parentDictionary->parent;
             }
         }
         push(@depsContent, "$className.h : ", join(" ", map { "$_.idl" } @ancestors), "\n");
@@ -4375,10 +4391,12 @@
     # - Generate dependencies.
     if ($writeDependencies) {
         my @ancestors;
-        my $parentDictionary = $dictionary->parent;
-        while (defined($parentDictionary)) {
-            push(@ancestors, $parentDictionary) if $codeGenerator->IsExternalDictionaryType($parentDictionary);
-            $parentDictionary = $codeGenerator->GetDictionaryByName($parentDictionary)->parent;
+        my $parentName = $dictionary->parent;
+        while (defined($parentName)) {
+            push(@ancestors, $parentName) if $codeGenerator->IsExternalDictionaryType($parentName);
+            my $parentDictionary = $codeGenerator->GetDictionaryByName($parentName);
+            assert("Unable to find definition for dictionary named '" . $parentName . "'!") unless $parentDictionary;
+            $parentName = $parentDictionary->parent;
         }
         push(@depsContent, "$className.h : ", join(" ", map { "$_.idl" } @ancestors), "\n");
         push(@depsContent, map { "$_.idl :\n" } @ancestors);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to