Add an 'isReadOnly' member to IDL parse tree structure
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 May 2013 17:42:17 +0000 (17:42 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 May 2013 17:42:17 +0000 (17:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=115704

Reviewed by Kentaro Hara.

Source/WebCore:

Add an 'isReadOnly' member to IDL parse tree structure by merging
https://chromium.googlesource.com/chromium/blink/+/d6add80ecd08bcd88a6ae0e1698d929830b3bd8b
and update Objective-C, C++, and GObject binding generators to use isReadOnly.

* bindings/scripts/CodeGeneratorCPP.pm:
(GenerateHeader):
(GenerateImplementation):
* bindings/scripts/CodeGeneratorGObject.pm:
(GetWriteableProperties):
(GenerateProperty):
(GenerateFunctions):
* bindings/scripts/CodeGeneratorJS.pm:
(IsReadonly):
* bindings/scripts/CodeGeneratorObjC.pm:
(GenerateHeader):
(GenerateImplementation):
* bindings/scripts/IDLParser.pm:
(parseAttributeRest):
(parseExceptionField):
(parseAttributeRestOld):

Tools:

Use newly added isReadOnly attribute.

* WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
(_generateHeaderFile):
(_generateImplementationFile):
(_staticValuesGetterImplementation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149679 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm
Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm
Source/WebCore/bindings/scripts/IDLParser.pm
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm

index f8a6ae84ee081c4a5bc6f829e1a61466428b876b..ff30b83a195a7e873cede71471689024e07cefea 100644 (file)
@@ -1,3 +1,31 @@
+2013-05-06  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Add an 'isReadOnly' member to IDL parse tree structure
+        https://bugs.webkit.org/show_bug.cgi?id=115704
+
+        Reviewed by Kentaro Hara.
+
+        Add an 'isReadOnly' member to IDL parse tree structure by merging
+        https://chromium.googlesource.com/chromium/blink/+/d6add80ecd08bcd88a6ae0e1698d929830b3bd8b
+        and update Objective-C, C++, and GObject binding generators to use isReadOnly.
+
+        * bindings/scripts/CodeGeneratorCPP.pm:
+        (GenerateHeader):
+        (GenerateImplementation):
+        * bindings/scripts/CodeGeneratorGObject.pm:
+        (GetWriteableProperties):
+        (GenerateProperty):
+        (GenerateFunctions):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (IsReadonly):
+        * bindings/scripts/CodeGeneratorObjC.pm:
+        (GenerateHeader):
+        (GenerateImplementation):
+        * bindings/scripts/IDLParser.pm:
+        (parseAttributeRest):
+        (parseExceptionField):
+        (parseAttributeRestOld):
+
 2013-05-07  Darin Adler  <darin@apple.com>
 
         Use OwnPtr instead of deleteAllValues in SMILTimeContainer
index 3f9f84bbef5522154aa130a145f6ddf263c687f2..e65fc2aed2ea8dd063cc267d9abcf8325d133462 100644 (file)
@@ -439,7 +439,6 @@ sub GenerateHeader
             my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature);
             my $attributeName = $attribute->signature->name;
             my $attributeType = GetCPPType($attribute->signature->type, 0);
-            my $attributeIsReadonly = ($attribute->type =~ /^readonly/);
             my $property = "";
             
             $property .= "#if ${attributeConditionalString}\n" if $attributeConditionalString;
@@ -455,7 +454,7 @@ sub GenerateHeader
 
             $property .= $declarationSuffix;
             push(@headerAttributes, $property);
-            if (!$attributeIsReadonly and !$attribute->signature->extendedAttributes->{"Replaceable"}) {
+            if (!$attribute->isReadOnly and !$attribute->signature->extendedAttributes->{"Replaceable"}) {
                 $property = "    void $setterName($attributeType)";
                 $property .= $declarationSuffix;
                 push(@headerAttributes, $property); 
@@ -696,7 +695,6 @@ sub GenerateImplementation
 
             my $attributeName = $attribute->signature->name;
             my $attributeType = GetCPPType($attribute->signature->type, 0);
-            my $attributeIsReadonly = ($attribute->type =~ /^readonly/);
             my $attributeIsNullable = $attribute->signature->isNullable;
 
             $attributeNames{$attributeName} = 1;
@@ -763,7 +761,7 @@ sub GenerateImplementation
             push(@implContent, "}\n\n");
 
             # - SETTER
-            if (!$attributeIsReadonly and !$attribute->signature->extendedAttributes->{"Replaceable"}) {
+            if (!$attribute->isReadOnly and !$attribute->signature->extendedAttributes->{"Replaceable"}) {
                 # Exception handling
                 my $hasSetterException = @{$attribute->setterExceptions};
 
index 02c2d3db6d5cc1f521fdfa8679828420587091c4..062639b6b3c472e9fbf6276a218eb99f222a78e4 100644 (file)
@@ -386,7 +386,6 @@ sub GetWriteableProperties {
     my @result = ();
 
     foreach my $property (@{$properties}) {
-        my $writeable = $property->type !~ /^readonly/;
         my $gtype = GetGValueTypeName($property->signature->type);
         my $hasGtypeSignature = ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" ||
                                  $gtype eq "uint64" || $gtype eq "ulong" || $gtype eq "long" || 
@@ -395,7 +394,7 @@ sub GetWriteableProperties {
         # FIXME: We are not generating setters for 'Replaceable'
         # attributes now, but we should somehow.
         my $replaceable = $property->signature->extendedAttributes->{"Replaceable"};
-        if ($writeable && $hasGtypeSignature && !$replaceable) {
+        if (!$property->isReadOnly && $hasGtypeSignature && !$replaceable) {
             push(@result, $property);
         }
     }
@@ -460,7 +459,7 @@ sub GenerateProperty {
 
     my $gtype = GetGValueTypeName($propType);
     my $gparamflag = "WEBKIT_PARAM_READABLE";
-    my $writeable = $attribute->type !~ /^readonly/;
+    my $writeable = !$attribute->isReadOnly;
     my $const = "read-only ";
     my $custom = $attribute->signature->extendedAttributes->{"Custom"};
     if ($writeable && $custom) {
@@ -1233,8 +1232,7 @@ sub GenerateFunctions {
 
         # FIXME: We are not generating setters for 'Replaceable'
         # attributes now, but we should somehow.
-        if ($attribute->type =~ /^readonly/ ||
-            $attribute->signature->extendedAttributes->{"Replaceable"}) {
+        if ($attribute->isReadOnly || $attribute->signature->extendedAttributes->{"Replaceable"}) {
             next TOP;
         }
         
index 2a680e5731baf2747d5471191749431d8fd4fd13..24d5c42299133938a30dcbe175c7443216647bea 100644 (file)
@@ -265,7 +265,7 @@ sub IsScriptProfileType
 sub IsReadonly
 {
     my $attribute = shift;
-    return $attribute->type =~ /readonly/ && !$attribute->signature->extendedAttributes->{"Replaceable"};
+    return $attribute->isReadOnly && !$attribute->signature->extendedAttributes->{"Replaceable"};
 }
 
 sub AddTypedefForScriptProfileType
index a48ccac4e40b1a4bbb9f3629d41a54b03bfb2a7f..16d52d2ba75a06e5e6fb206f96d0be651db02a03 100644 (file)
@@ -788,9 +788,7 @@ sub GenerateHeader
             }
 
             my $attributeType = GetObjCType($attribute->signature->type);
-            my $attributeIsReadonly = ($attribute->type =~ /^readonly/);
-
-            my $property = "\@property" . GetPropertyAttributes($attribute->signature->type, $attributeIsReadonly);
+            my $property = "\@property" . GetPropertyAttributes($attribute->signature->type, $attribute->isReadOnly);
             # Some SVGFE*Element.idl use 'operator' as attribute name, rewrite as '_operator' to avoid clashes with C/C++
             $attributeName =~ s/operator/_operator/ if ($attributeName =~ /operator/);
             $property .= " " . $attributeType . ($attributeType =~ /\*$/ ? "" : " ") . $attributeName;
@@ -1166,7 +1164,6 @@ sub GenerateImplementation
 
             my $attributeName = $attribute->signature->name;
             my $attributeType = GetObjCType($attribute->signature->type);
-            my $attributeIsReadonly = ($attribute->type =~ /^readonly/);
             my $attributeClassName = GetClassName($attribute->signature->type);
 
             my $attributeInterfaceName = $attributeName;
@@ -1381,7 +1378,7 @@ sub GenerateImplementation
             push(@implContent, "}\n");
 
             # - SETTER
-            if (!$attributeIsReadonly) {
+            if (!$attribute->isReadOnly) {
                 # Exception handling
                 my $hasSetterException = @{$attribute->setterExceptions};
 
index cc4e6a0792cf77ca8cf5334e92835f9a43d138e1..843d9166746833c32b92c2ed1436bb6df8a3624b 100644 (file)
@@ -66,6 +66,7 @@ struct( domFunction => {
 struct( domAttribute => {
     type => '$',              # Attribute type (including namespace)
     isStatic => '$',
+    isReadOnly => '$',
     signature => '$',         # Attribute signature
     getterExceptions => '@',  # Possibly raised exceptions.
     setterExceptions => '@',  # Possibly raised exceptions.
@@ -1141,7 +1142,8 @@ sub parseAttributeRest
     if ($next->value() =~ /$nextAttributeRest_1/) {
         my $newDataNode = domAttribute->new();
         if ($self->parseReadOnly()) {
-            $newDataNode->type("readonly attribute");
+            $newDataNode->type("attribute");
+            $newDataNode->isReadOnly(1);
         } else {
             $newDataNode->type("attribute");
         }
@@ -1498,7 +1500,8 @@ sub parseExceptionField
     my $next = $self->nextToken();
     if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
         my $newDataNode = domAttribute->new();
-        $newDataNode->type("readonly attribute");
+        $newDataNode->type("attribute");
+        $newDataNode->isReadOnly(1);
         $newDataNode->signature(domSignature->new());
         $newDataNode->signature->type($self->parseType());
         my $token = $self->getToken();
@@ -2414,7 +2417,8 @@ sub parseAttributeRestOld
     if ($next->value() =~ /$nextAttributeRest_1/) {
         my $newDataNode = domAttribute->new();
         if ($self->parseReadOnly()) {
-            $newDataNode->type("readonly attribute");
+            $newDataNode->type("attribute");
+            $newDataNode->isReadOnly(1);
         } else {
             $newDataNode->type("attribute");
         }
index 667937c6a4bf3428bbed91a2615f2f2d28ceee41..7d049eb33d87d46f76e2aa4e6c6ee03342c3725e 100644 (file)
@@ -1,3 +1,17 @@
+2013-05-06  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Add an 'isReadOnly' member to IDL parse tree structure
+        https://bugs.webkit.org/show_bug.cgi?id=115704
+
+        Reviewed by Kentaro Hara.
+
+        Use newly added isReadOnly attribute.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/CodeGeneratorTestRunner.pm:
+        (_generateHeaderFile):
+        (_generateImplementationFile):
+        (_staticValuesGetterImplementation):
+
 2013-05-07  Anders Carlsson  <andersca@apple.com>
 
         Remove AlwaysInline.h from WTF
index 7383946b3e015bc76f2405210b334065f4474369..73051ffcbf866bb67da2d18dca4b3bdc071dbc59 100644 (file)
@@ -186,7 +186,7 @@ EOF
         push(@contents, "\n    // Attributes\n\n");
         foreach my $attribute (@attributes) {
             push(@contents, "    static JSValueRef @{[$self->_getterName($attribute)]}(JSContextRef, JSObjectRef, JSStringRef, JSValueRef*);\n");
-            push(@contents, "    static bool @{[$self->_setterName($attribute)]}(JSContextRef, JSObjectRef, JSStringRef, JSValueRef, JSValueRef*);\n") unless $attribute->type =~ /^readonly/;
+            push(@contents, "    static bool @{[$self->_setterName($attribute)]}(JSContextRef, JSObjectRef, JSStringRef, JSValueRef, JSValueRef*);\n") unless $attribute->isReadOnly;
         }
     }
 
@@ -330,7 +330,7 @@ JSValueRef ${className}::${getterName}(JSContextRef context, JSObjectRef object,
 }
 EOF
 
-            unless ($attribute->type =~ /^readonly/) {
+            unless ($attribute->isReadOnly) {
                 push(@contents, <<EOF);
 
 bool ${className}::@{[$self->_setterName($attribute)]}(JSContextRef context, JSObjectRef object, JSStringRef, JSValueRef value, JSValueRef* exception)
@@ -555,11 +555,10 @@ sub _staticValuesGetterImplementation
         return if $_->signature->extendedAttributes->{"NoImplementation"};
 
         my $attributeName = $_->signature->name;
-        my $attributeIsReadonly = $_->type =~ /^readonly/;
         my $getterName = $self->_getterName($_);
-        my $setterName = $attributeIsReadonly ? "0" : $self->_setterName($_);
+        my $setterName = $_->isReadOnly ? "0" : $self->_setterName($_);
         my @attributes = qw(kJSPropertyAttributeDontDelete);
-        push(@attributes, "kJSPropertyAttributeReadOnly") if $attributeIsReadonly;
+        push(@attributes, "kJSPropertyAttributeReadOnly") if $_->isReadOnly;
         push(@attributes, "kJSPropertyAttributeDontEnum") if $_->signature->extendedAttributes->{"DontEnum"};
 
         return "{ \"$attributeName\", $getterName, $setterName, " . join(" | ", @attributes) . " }";