Bug 161793 - JSDOMBindings' toArguments() should return a more descriptive object
Summary: JSDOMBindings' toArguments() should return a more descriptive object
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nael Ouedraogo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-09 05:37 PDT by Nael Ouedraogo
Modified: 2016-09-20 11:55 PDT (History)
4 users (show)

See Also:


Attachments
Patch (11.36 KB, patch)
2016-09-09 07:06 PDT, Nael Ouedraogo
no flags Details | Formatted Diff | Diff
Patch (6.22 KB, patch)
2016-09-13 01:52 PDT, Nael Ouedraogo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nael Ouedraogo 2016-09-09 05:37:21 PDT
JSDOMBindings' toArguments() returns a std::pair of argumentIndex and Optional. In JS bindings code generator, use of ".first" and ".second" to access to members is hard to read. 

We should use a struct instead to be able to name the members.
Comment 1 Nael Ouedraogo 2016-09-09 07:06:13 PDT
Created attachment 288400 [details]
Patch
Comment 2 Chris Dumez 2016-09-09 09:11:20 PDT
Comment on attachment 288400 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=288400&action=review

> Source/WebCore/bindings/js/JSDOMBinding.h:357
> +struct VariadicHelperResult {

Would something simpler work? E.g.

struct Result {
    size_t argumentIndex;
    Optional<Container> arguments;
}

Also, could we declare this struct inside the VariadicHelper struct?

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:-1107
> -    

In the future, please try to avoid this kind of unrelated spacing changes.
Comment 3 Chris Dumez 2016-09-09 09:13:14 PDT
Comment on attachment 288400 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=288400&action=review

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3993
> +            $value = "WTFMove($name.arguments.value())";

Why is this change needed? wouldn't this work?
$value = "WTFMove(*$name.arguments)";
Comment 4 Nael Ouedraogo 2016-09-13 01:52:21 PDT
Created attachment 288681 [details]
Patch
Comment 5 Nael Ouedraogo 2016-09-13 01:56:40 PDT
Thanks for the review.

> > Source/WebCore/bindings/js/JSDOMBinding.h:357
> > +struct VariadicHelperResult {
> 
> Would something simpler work? E.g.
> 
> struct Result {
>     size_t argumentIndex;
>     Optional<Container> arguments;
> }
> 
> Also, could we declare this struct inside the VariadicHelper struct?
Ok, done in the uploaded patch. 

> > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:-1107
> > -    
> 
> In the future, please try to avoid this kind of unrelated spacing changes.
Ok, I thought it was good to remove trailing whitespaces. 

> > Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:3993
> > +            $value = "WTFMove($name.arguments.value())";
> 
> Why is this change needed? wouldn't this work?
> $value = "WTFMove(*$name.arguments)";
Yes, it works also but it seems that value() is generally used in WebKit  instead of * with Optional value (c.f. Bug 158835#c14).
Comment 6 WebKit Commit Bot 2016-09-19 02:02:50 PDT
Comment on attachment 288681 [details]
Patch

Clearing flags on attachment: 288681

Committed r206090: <http://trac.webkit.org/changeset/206090>
Comment 7 WebKit Commit Bot 2016-09-19 02:02:54 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Darin Adler 2016-09-19 13:55:47 PDT
Comment on attachment 288681 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=288681&action=review

> Source/WebCore/bindings/js/JSDOMBinding.h:363
> +        Result(size_t argumentIndex, Optional<Container>&& arguments)
> +            : argumentIndex(argumentIndex)
> +            , arguments(WTFMove(arguments))
> +        {
> +        }

We should not include this constructor. Member-wise initialization should accomplish the same thing.
Comment 9 Nael Ouedraogo 2016-09-20 11:55:21 PDT
(In reply to comment #8)
> Comment on attachment 288681 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=288681&action=review
> 
> > Source/WebCore/bindings/js/JSDOMBinding.h:363
> > +        Result(size_t argumentIndex, Optional<Container>&& arguments)
> > +            : argumentIndex(argumentIndex)
> > +            , arguments(WTFMove(arguments))
> > +        {
> > +        }
> 
> We should not include this constructor. Member-wise initialization should
> accomplish the same thing.

Ok, I filed bug 162298 for this.