[pigeon] Fix C++ generator's handling of non-class host APIs#2270
Conversation
|
RVO is confusing. Still reviewing this. |
|
I'm thinking here that since all the custom messages are also wrapped with an |
|
No, the cases where RVO doesn't work are more subtle than that. It's something more like (I don't trust that I understand it well enough to explain it fully correctly) if the return statement itself has runtime switching RVO doesn't work. To make sure my understanding of the basic case is correct, I did an instrumented test. This does RVO (Foo is an object that wraps an int): But this doesn't: The latter appears to call the move constructor if possible, or the copy constructor if there isn't one, for the return. ( Given how cumbersome the latter is to write, I would expect RVO to be the common case. |
|
(flutter/plugins#6035 is an example of this PR in action if it's helpful for reviewing) |
|
@azchohfi Do you think you'll be able to review this in the next couple of weeks? If not, @gaaclarke could you take a look? |
|
I completely forgot about this. I had half-reviewed it already, but thanks for the ping. Will do! |
azchohfi
left a comment
There was a problem hiding this comment.
So much cleaner... This is great!
Also loved that we now have a much better test coverage!
|
Thanks! I'll try to get to the other follow-ups (style fixes, Flutter API tests and type changes) relatively soon now that this is complete. |
Overhauls the way arguments and return types are handled for host APIs:
unique_ptrfor return types, which are awkward to use and still had a copy at the encoding step, to an approach that relies on move semantics and RVO for efficiency. Copies are possible (e.g., if someone defeats RVO in their host API implementation), but it should hopefully give us a good balance of efficiency and ease of use.This ports several of the missing native tests from iOS to Windows in order to give meaningful coverage of these changes. It also adds significant Dart unit testing of the type handling.
To limit PR scope, this does not address:
Those can be fixed in follow-ups.
Fixes flutter/flutter#105164
Fixes flutter/flutter#105057
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).