- a/Source/WebCore/ChangeLog +19 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-01-08  Kentaro Hara  <haraken@chromium.org>
2
3
        [Refactoring] Use join(", ", @arguments) to build a method argument
4
        string in CodeGeneratorV8.pm
5
        https://bugs.webkit.org/show_bug.cgi?id=75828
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        The code in CodeGeneratorV8.pm to build a method argument string is dirty
10
        and error-prone. It is concatenating arguments one by one judging whether
11
        ", " is necessary or not. This patch refactors the code so that it pushes
12
        all arguments into @arguments and then builds a method string by
13
        join(", ", @arguments).
14
15
        Test: bindings/scripts/test/*
16
17
        * bindings/scripts/CodeGeneratorV8.pm:
18
        (GenerateFunctionCallString):
19
1
2012-01-08  ChangSeok Oh  <shivamidow@gmail.com>
20
2012-01-08  ChangSeok Oh  <shivamidow@gmail.com>
2
21
3
        Memory allocation mismatch by using adoptArrayPtr in GraphicsContext3DOpenGL.cpp
22
        Memory allocation mismatch by using adoptArrayPtr in GraphicsContext3DOpenGL.cpp
- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm -19 / +10 lines
Lines 3185-3195 sub GenerateFunctionCallString() a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm_sec1
3185
        $name = $function->signature->extendedAttributes->{"ImplementationFunction"};
3185
        $name = $function->signature->extendedAttributes->{"ImplementationFunction"};
3186
    }
3186
    }
3187
3187
3188
    my $functionString = "imp->${name}(";
3188
    my @arguments;
3189
    if ($function->isStatic) {
3190
        $functionString = "${implClassName}::${name}(";
3191
    }
3192
3193
    my $index = 0;
3189
    my $index = 0;
3194
    my $hasScriptState = 0;
3190
    my $hasScriptState = 0;
3195
3191
Lines 3206-3213 sub GenerateFunctionCallString() a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm_sec2
3206
            $result .= $indent . "    return v8::Undefined();\n";
3202
            $result .= $indent . "    return v8::Undefined();\n";
3207
            $callWithArg = "scriptContext";
3203
            $callWithArg = "scriptContext";
3208
        }
3204
        }
3209
        $functionString .= ", " if $index;
3205
        push @arguments, $callWithArg;
3210
        $functionString .= $callWithArg;
3211
        $index++;
3206
        $index++;
3212
        $numberOfParameters++
3207
        $numberOfParameters++
3213
    }
3208
    }
Lines 3216-3253 sub GenerateFunctionCallString() a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm_sec3
3216
        if ($index eq $numberOfParameters) {
3211
        if ($index eq $numberOfParameters) {
3217
            last;
3212
            last;
3218
        }
3213
        }
3219
        $functionString .= ", " if $index;
3220
        my $paramName = $parameter->name;
3214
        my $paramName = $parameter->name;
3221
        my $paramType = $parameter->type;
3215
        my $paramType = $parameter->type;
3222
3216
3223
        if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") {
3217
        if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") {
3224
            $functionString .= "$paramName.get()";
3218
            push @arguments, "$paramName.get()";
3225
        } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $implClassName =~ /List$/) {
3219
        } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $implClassName =~ /List$/) {
3226
            $functionString .= "$paramName->propertyReference()";
3220
            push @arguments, "$paramName->propertyReference()";
3227
            $result .= $indent . "if (!$paramName) {\n";
3221
            $result .= $indent . "if (!$paramName) {\n";
3228
            $result .= $indent . "    V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR);\n";
3222
            $result .= $indent . "    V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR);\n";
3229
            $result .= $indent . "    return v8::Handle<v8::Value>();\n";
3223
            $result .= $indent . "    return v8::Handle<v8::Value>();\n";
3230
            $result .= $indent . "}\n";
3224
            $result .= $indent . "}\n";
3231
        } elsif ($parameter->type eq "SVGMatrix" and $implClassName eq "SVGTransformList") {
3225
        } elsif ($parameter->type eq "SVGMatrix" and $implClassName eq "SVGTransformList") {
3232
            $functionString .= "$paramName.get()";
3226
            push @arguments, "$paramName.get()";
3233
        } else {
3227
        } else {
3234
            $functionString .= $paramName;
3228
            push @arguments, $paramName;
3235
        }
3229
        }
3236
        $index++;
3230
        $index++;
3237
    }
3231
    }
3238
3232
3239
    if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
3233
    if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) {
3240
        $functionString .= ", " if $index;
3234
        push @arguments, "scriptArguments, callStack";
3241
        $functionString .= "scriptArguments, callStack";
3242
        $index += 2;
3243
    }
3235
    }
3244
3236
3245
    if (@{$function->raisesExceptions}) {
3237
    if (@{$function->raisesExceptions}) {
3246
        $functionString .= ", " if $index;
3238
        push @arguments, "ec";
3247
        $functionString .= "ec";
3248
        $index++;
3249
    }
3239
    }
3250
    $functionString .= ")";
3240
3241
    my $functionString = ($function->isStatic ? "${implClassName}::${name}(" : "imp->${name}(") . join(", ", @arguments) . ")";
3251
3242
3252
    my $return = "result";
3243
    my $return = "result";
3253
    my $returnIsRef = IsRefPtrType($returnType);
3244
    my $returnIsRef = IsRefPtrType($returnType);

Return to Bug 75828