Bug 157250 - Pass reference instead of pointer to IDL attribute setters if not nullable
Summary: Pass reference instead of pointer to IDL attribute setters if not nullable
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-01 14:51 PDT by Chris Dumez
Modified: 2016-05-01 21:20 PDT (History)
4 users (show)

See Also:


Attachments
Patch (49.79 KB, patch)
2016-05-01 16:56 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (54.15 KB, patch)
2016-05-01 17:09 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (63.71 KB, patch)
2016-05-01 17:19 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (61.47 KB, patch)
2016-05-01 17:49 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (61.48 KB, patch)
2016-05-01 21:18 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-05-01 14:51:04 PDT
Pass reference instead of pointer to IDL attribute setters if not nullable.
Comment 1 Chris Dumez 2016-05-01 16:56:34 PDT
Created attachment 277874 [details]
Patch
Comment 2 Chris Dumez 2016-05-01 17:09:02 PDT
Created attachment 277877 [details]
Patch
Comment 3 Chris Dumez 2016-05-01 17:19:18 PDT
Created attachment 277878 [details]
Patch
Comment 4 Chris Dumez 2016-05-01 17:19:38 PDT
Another attempt to make the GObject bindings happy :/
Comment 5 Darin Adler 2016-05-01 17:36:30 PDT
Comment on attachment 277878 [details]
Patch

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

> Source/WebCore/ChangeLog:12
> +        There is not intended Web-exposed behavior change.

should be "no intended"

> Source/WebCore/ChangeLog:38
> +        (WebCore::setJSTestObjTestObjAttr):
> +        (WebCore::setJSTestObjLenientTestObjAttr):
> +        (WebCore::setJSTestObjXMLObjAttr):
> +        (WebCore::setJSTestObjTypedArrayAttr):
> +        (WebCore::setJSTestObjStrictTypeCheckingAttribute):
> +        (WebCore::setJSTestObjWithScriptExecutionContextAttribute):
> +        (WebCore::setJSTestObjWithScriptStateAttributeRaises):
> +        (WebCore::setJSTestObjWithScriptExecutionContextAttributeRaises):
> +        (WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateAttribute):
> +        (WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateAttributeRaises):
> +        (WebCore::setJSTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute):
> +        (WebCore::setJSTestObjWithScriptArgumentsAndCallStackAttribute):
> +        (WebCore::setJSTestObjWithCallWithAndSetterCallWithAttribute): Deleted.

I suggest removing the lists of function names for the regenerated test output.

> Source/WebCore/bindings/js/JSDataCueCustom.cpp:92
>              return JSValue::encode(JSValue());

So random to use this value here unlike other similar call sites. I think we need a more standard thing to return when we have exceptions. JSValue::encode(jsUndefined()) is so long and it shouldn’t matter what we return.

> Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm:1113
> +            $paramName = "*$paramName" if ($codeGenerator->ShouldPassWrapperByReference($param, $parentNode));

perl coding style omits the parentheses after if when doing it like this, and I like that

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2867
> +                    push(@implContent, "        return false;\n");

Maybe we should return { } in all these places where there is an exception and it doesn’t matter what we return.

> Source/WebCore/dom/NodeIterator.h:63
> +            NodePointer() = default;
> +            NodePointer(Node&, bool);

Do we really need these constructors at all? Could we just use aggregate initialization syntax instead and write { &node, false }. Where are the call sites that this makes better?

> Source/WebCore/dom/TreeWalker.h:45
> +        Node& currentNode() { return m_current.get(); }
> +        const Node& currentNode() const { return m_current.get(); }

This need to overload irritates me a bit. It seems fine to me to get a Node& out of a const TreeWalker; just seems this is a sort of “bug” in Ref; would not be an issue if it was an actual reference. I’d prefer not to have these two overloads. Maybe we can use const_cast or something.

> Source/WebCore/dom/TreeWalker.h:62
> +        Node* setCurrent(Ref<Node>&&);

The return value for this could be Node&.
Comment 6 Chris Dumez 2016-05-01 17:48:51 PDT
Comment on attachment 277878 [details]
Patch

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

>> Source/WebCore/ChangeLog:12
>> +        There is not intended Web-exposed behavior change.
> 
> should be "no intended"

OK

>> Source/WebCore/ChangeLog:38
>> +        (WebCore::setJSTestObjWithCallWithAndSetterCallWithAttribute): Deleted.
> 
> I suggest removing the lists of function names for the regenerated test output.

OK

>> Source/WebCore/bindings/js/JSDataCueCustom.cpp:92
>>              return JSValue::encode(JSValue());
> 
> So random to use this value here unlike other similar call sites. I think we need a more standard thing to return when we have exceptions. JSValue::encode(jsUndefined()) is so long and it shouldn’t matter what we return.

Ok, I think I'll return JSValue::encode(jsUndefined()) for now, for consistency.

>> Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm:1113
>> +            $paramName = "*$paramName" if ($codeGenerator->ShouldPassWrapperByReference($param, $parentNode));
> 
> perl coding style omits the parentheses after if when doing it like this, and I like that

OK.

>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:2867
>> +                    push(@implContent, "        return false;\n");
> 
> Maybe we should return { } in all these places where there is an exception and it doesn’t matter what we return.

Everything else in this function already returns false in case of error. The setters return a boolean.
Comment 7 Chris Dumez 2016-05-01 17:49:20 PDT
Created attachment 277881 [details]
Patch
Comment 8 Darin Adler 2016-05-01 21:04:26 PDT
Comment on attachment 277881 [details]
Patch

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

> Source/WebCore/bindings/js/JSDataCueCustom.cpp:90
> +        if (!data) {

UNLIKELY, I think
Comment 9 Chris Dumez 2016-05-01 21:18:50 PDT
Created attachment 277889 [details]
Patch
Comment 10 Chris Dumez 2016-05-01 21:20:45 PDT
Comment on attachment 277889 [details]
Patch

Clearing flags on attachment: 277889

Committed r200316: <http://trac.webkit.org/changeset/200316>
Comment 11 Chris Dumez 2016-05-01 21:20:50 PDT
All reviewed patches have been landed.  Closing bug.