Bug 82599 - IDLParser.pm should be able to parse sequence<T> as method argument
Summary: IDLParser.pm should be able to parse sequence<T> as method argument
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Vineet Chaudhary (vineetc)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-29 05:12 PDT by Vineet Chaudhary (vineetc)
Modified: 2013-02-07 18:56 PST (History)
5 users (show)

See Also:


Attachments
proposed patch (deleted)
2012-03-29 05:25 PDT, Vineet Chaudhary (vineetc)
haraken: review-
haraken: commit-queue-
Details | Formatted Diff | Diff
updated_patch (21.40 KB, patch)
2012-03-29 12:04 PDT, Vineet Chaudhary (vineetc)
haraken: review-
Details | Formatted Diff | Diff
Patch (22.74 KB, patch)
2012-03-30 02:47 PDT, Vineet Chaudhary (vineetc)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vineet Chaudhary (vineetc) 2012-03-29 05:12:11 PDT
Currently IDLParser.pm is not able to parse sequence<T> if it is one methods argument.
Comment 1 Vineet Chaudhary (vineetc) 2012-03-29 05:25:15 PDT
Created attachment 134554 [details]
proposed patch

Attaching proposed patch to get comments.
This is to add support for parser to parse arguments of type sequence<T>.
Though currently no function Source Code passes sequence<T> as argument but we can consider this.

Please let me know your review comments on this. Thanks.
Comment 2 Kentaro Hara 2012-03-29 05:30:24 PDT
Comment on attachment 134554 [details]
proposed patch

The patch looks OK.
Comment 3 Vineet Chaudhary (vineetc) 2012-03-29 05:35:11 PDT
Comment on attachment 134554 [details]
proposed patch

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

Thanks haraken for quick review.

> Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp:697
>  {


Just doubtful here "WebDOMsequence<ScriptProfile>& sequenceArg" is this desired? Or may be this can be fixed when we actually start using sequence<T> as argument.
Comment 4 Vineet Chaudhary (vineetc) 2012-03-29 05:39:52 PDT
Comment on attachment 134554 [details]
proposed patch

Marking for review.
Comment 5 Kentaro Hara 2012-03-29 05:42:59 PDT
Comment on attachment 134554 [details]
proposed patch

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

>> Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp:697
>>  {
> 
> Just doubtful here "WebDOMsequence<ScriptProfile>& sequenceArg" is this desired? Or may be this can be fixed when we actually start using sequence<T> as argument.

Oh, good catch! We are not planning to support sequence<T> in ObjC, GObject and CPP, for now. Then shall we skip generating code for sequence<T> in those three bindings? (See SkipFunction() in CodeGeneratorGObject.pm, ShouldSkipType() in CodeGeneratorCPP.pm. You might need to add something like it to CodeGeneratorObjC.pm.)
Comment 6 Vineet Chaudhary (vineetc) 2012-03-29 05:45:00 PDT
(In reply to comment #5)
> (From update of attachment 134554 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=134554&action=review
> 
> >> Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp:697
> >>  {
> > 
> > Just doubtful here "WebDOMsequence<ScriptProfile>& sequenceArg" is this desired? Or may be this can be fixed when we actually start using sequence<T> as argument.
> 
> Oh, good catch! We are not planning to support sequence<T> in ObjC, GObject and CPP, for now. Then shall we skip generating code for sequence<T> in those three bindings? (See SkipFunction() in CodeGeneratorGObject.pm, ShouldSkipType() in CodeGeneratorCPP.pm. You might need to add something like it to CodeGeneratorObjC.pm.)

Sure I will update patch :)
Comment 7 Adam Barth 2012-03-29 10:32:03 PDT
Is there an example of a feature that would use this functionality?
Comment 8 Vineet Chaudhary (vineetc) 2012-03-29 12:03:24 PDT
(In reply to comment #7)
> Is there an example of a feature that would use this functionality?

As of now we don't have any plan to use this functionality but we can consider the using sequence<T> in implementations like 
http://trac.webkit.org/browser/trunk/Source/WebCore/dom/MessagePort.idl?rev=106737#L40
where it passes Array.
Comment 9 Vineet Chaudhary (vineetc) 2012-03-29 12:04:36 PDT
Created attachment 134636 [details]
updated_patch
Comment 10 Adam Barth 2012-03-29 14:29:11 PDT
I would have thought in-parameters would use T[] rather than Sequence<T>, but I'm not sure I fully understand the subtle differences between the two.
Comment 11 Kentaro Hara 2012-03-29 17:00:19 PDT
Comment on attachment 134636 [details]
updated_patch

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

> Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm:472
> +                if ($codeGenerator->GetArrayType($param->type)) {
> +                    next TOP;
> +                }

Scattering this kind of code around is a bit dirty. Shall we put the code in ShouldSkipType($function)? e.g.

sub ShouldSkipType() {
  ...;
  foreach my $param (@{$function->parameters}) {
    return 1 if $codeGenerator->GetArrayType($param->type);
  }
  ...;
}

Same comments for all "next TOP" in this patch.

> Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm:848
>          foreach my $function (@{$dataNode->functions}) {

You can put something like ShouldSkipType() here. Maybe you need to prepare ShouldSkipType() in CodeGeneratorObjC.pm.

> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:3606
> +                    AddToImplIncludes($arrayType);

This should be "${arrayType}.h"
Comment 12 Kentaro Hara 2012-03-29 17:00:50 PDT
(In reply to comment #10)
> I would have thought in-parameters would use T[] rather than Sequence<T>, but I'm not sure I fully understand the subtle differences between the two.

vineet: Would you confirm the spec around this issue?
Comment 13 Vineet Chaudhary (vineetc) 2012-03-30 02:42:49 PDT
(In reply to comment #12)
> (In reply to comment #10)
> > I would have thought in-parameters would use T[] rather than Sequence<T>, but I'm not sure I fully understand the subtle differences between the two.
> 
> vineet: Would you confirm the spec around this issue?

While going through spec. for MessagePort http://dev.w3.org/html5/postmsg/#dom-messageport-postmessage or http://www.w3.org/TR/html5/comms.html#messageportarray

The signature of postMessage() is like :
void postMessage(any message, optional sequence<Transferable> transfer);

Does that means in-parameter can use sequence<T> ?
Comment 14 Vineet Chaudhary (vineetc) 2012-03-30 02:47:12 PDT
(In reply to comment #11)
> (From update of attachment 134636 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=134636&action=review

> Scattering this kind of code around is a bit dirty. Shall we put the code in ShouldSkipType($function)? e.g.
> 

> You can put something like ShouldSkipType() here. Maybe you need to prepare ShouldSkipType() in CodeGeneratorObjC.pm.

Added SkipFuntion and SkipAttribute.
The reason we could not keep common implementation as SkipType is 
foreach my $param (@{$function->parameters}) 

Attributes doesn't have call to "parameters" so I though of having separate functions is it oke?


> This should be "${arrayType}.h"
Done.
Comment 15 Vineet Chaudhary (vineetc) 2012-03-30 02:47:54 PDT
Created attachment 134756 [details]
Patch
Comment 16 Kentaro Hara 2012-03-30 04:06:16 PDT
Comment on attachment 134756 [details]
Patch

Thanks for the patch!
Comment 17 Kentaro Hara 2012-03-30 04:06:27 PDT
(In reply to comment #13)
> While going through spec. for MessagePort http://dev.w3.org/html5/postmsg/#dom-messageport-postmessage or http://www.w3.org/TR/html5/comms.html#messageportarray
> 
> The signature of postMessage() is like :
> void postMessage(any message, optional sequence<Transferable> transfer);
> 
> Does that means in-parameter can use sequence<T> ?

Thanks for the clarification. I think the spec supports your patch.

(In reply to comment #14)
> Added SkipFuntion and SkipAttribute.
> The reason we could not keep common implementation as SkipType is 
> foreach my $param (@{$function->parameters}) 
> 
> Attributes doesn't have call to "parameters" so I though of having separate functions is it oke?

Yes, it is a desirable change.
Comment 18 Vineet Chaudhary (vineetc) 2012-03-30 04:16:15 PDT
Comment on attachment 134756 [details]
Patch

(In reply to comment #17)
> (In reply to comment #13)
> > While going through spec. for MessagePort http://dev.w3.org/html5/postmsg/#dom-messageport-postmessage or http://www.w3.org/TR/html5/comms.html#messageportarray
> > 
> > The signature of postMessage() is like :
> > void postMessage(any message, optional sequence<Transferable> transfer);
> > 
> > Does that means in-parameter can use sequence<T> ?
> 
> Thanks for the clarification. I think the spec supports your patch.

Thanks haraken.. :) Should I take this as next <TO_DO> task..?
Comment 19 Kentaro Hara 2012-03-30 04:18:41 PDT
(In reply to comment #18)
> Thanks haraken.. :) Should I take this as next <TO_DO> task..?

We are always happy to kill custom bindings:) (unless it messes code generators)
Comment 20 WebKit Review Bot 2012-03-30 04:54:17 PDT
Comment on attachment 134756 [details]
Patch

Clearing flags on attachment: 134756

Committed r112653: <http://trac.webkit.org/changeset/112653>
Comment 21 WebKit Review Bot 2012-03-30 04:54:23 PDT
All reviewed patches have been landed.  Closing bug.