WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 162919
Generate passing union types as part of a functions variadic arguments
https://bugs.webkit.org/show_bug.cgi?id=162919
Summary
Generate passing union types as part of a functions variadic arguments
Sam Weinig
Reported
2016-10-04 10:44:06 PDT
Autogenerate passing union types as part of a functions variadic arguments
Attachments
Patch
(64.67 KB, patch)
2016-10-04 10:55 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(64.60 KB, patch)
2016-10-04 11:40 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(64.61 KB, patch)
2016-10-04 11:52 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(64.60 KB, patch)
2016-10-04 12:47 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(64.64 KB, patch)
2016-10-04 13:46 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(64.70 KB, patch)
2016-10-04 15:33 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(66.28 KB, patch)
2016-10-05 12:36 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(65.83 KB, patch)
2016-10-06 12:51 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2016-10-04 10:55:38 PDT
Created
attachment 290620
[details]
Patch
Sam Weinig
Comment 2
2016-10-04 11:40:45 PDT
Created
attachment 290627
[details]
Patch
Sam Weinig
Comment 3
2016-10-04 11:52:47 PDT
Created
attachment 290628
[details]
Patch
Sam Weinig
Comment 4
2016-10-04 12:47:46 PDT
Created
attachment 290636
[details]
Patch
Sam Weinig
Comment 5
2016-10-04 13:46:34 PDT
Created
attachment 290639
[details]
Patch
Sam Weinig
Comment 6
2016-10-04 15:33:38 PDT
Created
attachment 290655
[details]
Patch
Chris Dumez
Comment 7
2016-10-04 16:39:28 PDT
Comment on
attachment 290655
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290655&action=review
> Source/WebCore/ChangeLog:12 > + * bindings/js/JSCharacterDataCustom.cpp: Removed.
Fails to build on Windows: C:\cygwin\home\buildbot\WebKit\Source\WebCore\bindings\js\JSBindingsAllInOne.cpp(44): fatal error C1083: Cannot open include file: 'JSCharacterDataCustom.cpp': No such file or directory [C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\Source\WebCore\WebCore.vcxproj]
Chris Dumez
Comment 8
2016-10-04 16:48:58 PDT
Comment on
attachment 290655
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290655&action=review
> Source/WebCore/bindings/js/JSDOMConvert.h:79 > + static Optional<T> convertFailable(JSC::ExecState& state, JSC::JSValue value)
I am not sure we need this, all convert() functions can already fail.
> Source/WebCore/bindings/js/JSDOMConvert.h:129 > + static Optional<Ref<T>> convertFailable(JSC::ExecState& state, JSC::JSValue value)
Why do we need the concept of 'Failable"? We previously converted interface types using convertWrapperType(). The way we check for failure is usually by checking if an exception was thrown via "state".
Chris Dumez
Comment 9
2016-10-04 17:00:04 PDT
Comment on
attachment 290655
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290655&action=review
Looks great otherwise.
> Source/WebCore/bindings/scripts/CodeGenerator.pm:637 > + push @flattenedMemberTypes, $object->GetFlattenedMemberTypes($memberType)
I think we usually use the version with the parentheses in this script: push().
> Source/WebCore/bindings/scripts/CodeGenerator.pm:639 > + push @flattenedMemberTypes, $memberType;
ditto.
Sam Weinig
Comment 10
2016-10-05 10:56:48 PDT
(In reply to
comment #8
)
> Comment on
attachment 290655
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=290655&action=review
> > > Source/WebCore/bindings/js/JSDOMConvert.h:79 > > + static Optional<T> convertFailable(JSC::ExecState& state, JSC::JSValue value) > > I am not sure we need this, all convert() functions can already fail. > > > Source/WebCore/bindings/js/JSDOMConvert.h:129 > > + static Optional<Ref<T>> convertFailable(JSC::ExecState& state, JSC::JSValue value) > > Why do we need the concept of 'Failable"? > > We previously converted interface types using convertWrapperType(). The way > we check for failure is usually by checking if an exception was thrown via > "state".
The issue is that I need to be able to return a Ref<T> from the convert function, since that is what the implementation files want in this case, but in the case that they fail, I cannot return a Ref<T>. So, returning an Optional<Ref<T>> is the way to go, and if I am doing that, I need to make it generic, so all converts must return an Optional<Foo>. Another way to go would be to have the convert function return a RefPtr<T> and have another static function on Converter that can transform the RefPtr<T> into a Ref<T> if there was no exception (and for non interface types, just pass the result through). Do you have a preference for either?
Chris Dumez
Comment 11
2016-10-05 11:37:24 PDT
(In reply to
comment #10
)
> (In reply to
comment #8
) > > Comment on
attachment 290655
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=290655&action=review
> > > > > Source/WebCore/bindings/js/JSDOMConvert.h:79 > > > + static Optional<T> convertFailable(JSC::ExecState& state, JSC::JSValue value) > > > > I am not sure we need this, all convert() functions can already fail. > > > > > Source/WebCore/bindings/js/JSDOMConvert.h:129 > > > + static Optional<Ref<T>> convertFailable(JSC::ExecState& state, JSC::JSValue value) > > > > Why do we need the concept of 'Failable"? > > > > We previously converted interface types using convertWrapperType(). The way > > we check for failure is usually by checking if an exception was thrown via > > "state". > > The issue is that I need to be able to return a Ref<T> from the convert > function, since that is what the implementation files want in this case, but > in the case that they fail, I cannot return a Ref<T>. So, returning an > Optional<Ref<T>> is the way to go, and if I am doing that, I need to make it > generic, so all converts must return an Optional<Foo>. > > Another way to go would be to have the convert function return a RefPtr<T> > and have another static function on Converter that can transform the > RefPtr<T> into a Ref<T> if there was no exception (and for non interface > types, just pass the result through). Do you have a preference for either?
My preference would be to rely on convertWrapperType() which returns a raw pointer. I don't think the implementation really needs a Ref<>. We can call convertWrapperType() with the right IsNullable parameter. Then the calling code just needs to check if it threw an exception. Why would the convert<> function ref the object? I understand that your call site currently eventually wants to ref it but in general we pass raw pointers (or C++ references when not nullable) to the implementation to avoid ref counting churn. We then let the implementation decide if it wants to ref it or not.
Sam Weinig
Comment 12
2016-10-05 12:36:01 PDT
Created
attachment 290739
[details]
Patch
Chris Dumez
Comment 13
2016-10-05 12:45:47 PDT
Comment on
attachment 290739
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290739&action=review
> Source/WebCore/bindings/js/JSDOMConvert.h:132 > + static Optional<Ref<T>> convertFailable(JSC::ExecState& state, JSC::JSValue value)
Still using convertFailable? All convert functions can already fail and there is already a convert function for wrapper types.
Sam Weinig
Comment 14
2016-10-06 12:51:20 PDT
Created
attachment 290852
[details]
Patch
Darin Adler
Comment 15
2016-10-06 12:52:42 PDT
Comment on
attachment 290739
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=290739&action=review
r=me but I think you should consider the comment Chris made about convertFailable.
> Source/WebCore/bindings/scripts/CodeGenerator.pm:666 > + if ($memberType->isNullable) { > + $count++; > + }
I like one-liner if for this kind of thing in perl.
> Source/WebCore/bindings/scripts/CodeGenerator.pm:670 > + if ($memberType->isUnion) { > + $count += $object->GetNumberOfNullableMemberTypes($memberType); > + }
Ditto.
> Source/WebCore/bindings/scripts/CodeGenerator.pm:683 > + if ($numberOfNullableMembers > 1) { > + assert("Union types must only have 0 or 1 nullable types."); > + }
Ditto.
> Source/WebCore/bindings/scripts/CodeGenerator.pm:689 > + if ($numberOfNullableMembers == 1) { > + push(@idlUnionMemberTypes, "IDLNull"); > + }
Ditto.
Darin Adler
Comment 16
2016-10-06 12:53:32 PDT
Sorry, my review comments (trivial tiny things) showed up just as you posted your new patch.
Sam Weinig
Comment 17
2016-10-08 12:09:46 PDT
Committed
r206956
: <
http://trac.webkit.org/changeset/206956
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug