New C++ FIDL bindings are here (an update on LLCPP)

70 views
Skip to first unread message

Yifei Teng

unread,
Jul 28, 2022, 12:22:10 PM7/28/22
to fidl-dev, anno...@fuchsia.dev

~ You may ignore if you don't write C++ ~

TLDR: We've added safe and ergonomic data types to the LLCPP FIDL bindings, and documented them. The combination is now called new C++ bindings.

 

The generated FIDL types in LLCPP, called "wire types'', aren't very easy to use: they're optimized for low-level, allocation-sensitive contexts (that's where the name "low-level C++ bindings'' originated). We've since introduced higher level, ergonomics focused generated types, called "natural types" or "natural domain objects", as well as client and server APIs that speak those types.

 

With this addition, LLCPP is no longer "low-level". It is now renamed to ✨ new C++ FIDL bindings ✨.

(You may have heard the name "unified C++ bindings" tossed around; that's what this used to be called but it didn't make the most sense hence this rebranding)


Check out the fuchsia.dev tutorials for more details on how to use them. As part of documenting the natural types we've revamped the wire types tutorials too!


More about the natural domain objects

See their documentation here.


The natural types embrace std:: containers and idioms. For example, a table is represented as a collection of std::optional<Field>s. A vector is std::vector<T>, etc. They also implement idiomatic C++ moves and copies and equality: a value type will be copyable, while a resource type is only movable.


If you've been using HLCPP in-tree, you're encouraged to switch to the new C++ bindings

- Using servers and clients from multiple threads is supported in a principled way.

- Client calls can turn into fpromise:: promises, easily avoid callback hell.

- Know exactly which async call failed, better error logging and error handling.

- Fallible operations are represented using fitx::result, playing nice with Fuchsia C++ at large.

 

If you've been using LLCPP, consider using the natural domain objects

The natural types own their children so you could move them around and return them from functions without worrying about lifetimes. The wire types (what you're likely using today) use unsafe borrowing hence are prone to use-after-frees. If you've been bothered by these errors or have written boilerplate to extend wire object lifetimes, switching to the natural domain objects in targeted places has the potential to simplify code.


Other minor mechanical things

When you use the wire types the FIDL library dependency used to have a suffix "_llcpp". As part of the rename, the build dependency suffix will become "_cpp_wire". You can use that suffix today and we'll migrate the rest.

Similarly, the header include pattern will become #include <lib/fidl/cpp/wire/…>. You can use that include pattern today.


Next steps in new C++ FIDL bindings

Fully support out-of-tree usage. Tracked by fxb/80525 (wire types) and fxb/92356 (natural types) respectively.


Cheers,

Yifei


Shai Barack

unread,
Jul 28, 2022, 12:30:17 PM7/28/22
to Yifei Teng, fidl-dev, announce
Thank you! This has been a recurring paper cut for me. Looking forward to not having to deal with this anymore. 🤣

--
All posts must follow the Fuchsia Code of Conduct https://fuchsia.dev/fuchsia-src/CODE_OF_CONDUCT or may be removed.
---
You received this message because you are subscribed to the Google Groups "announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to announce+u...@fuchsia.dev.
To view this discussion on the web visit https://groups.google.com/a/fuchsia.dev/d/msgid/announce/CANbn4XBaBCfBQWU5KE9O5vcbpzBdj--0JdH9jh0jaz1%3DP%2B0mgA%40mail.gmail.com.

Suraj Malhotra

unread,
Jul 28, 2022, 6:00:32 PM7/28/22
to Yifei Teng, fidl-dev, anno...@fuchsia.dev
Really happy to see this. Does this announcement mean that HLCPP usage is defacto deprecated (at least in tree)? Are there any plans to limit new usages via an allow list?

--
All posts must follow the Fuchsia Code of Conduct https://fuchsia.dev/fuchsia-src/CODE_OF_CONDUCT or may be removed.
---
You received this message because you are subscribed to the Google Groups "fidl-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fidl-dev+u...@fuchsia.dev.
To view this discussion on the web visit https://groups.google.com/a/fuchsia.dev/d/msgid/fidl-dev/CANbn4XBaBCfBQWU5KE9O5vcbpzBdj--0JdH9jh0jaz1%3DP%2B0mgA%40mail.gmail.com.

Devon H. O'Dell

unread,
Jul 28, 2022, 8:02:59 PM7/28/22
to Suraj Malhotra, Yifei Teng, fidl-dev
(Removing announce@, which isn't a discussion list. Please don't cross-post announcements.)

Kind regards,

--dho

Yifei Teng

unread,
Jul 29, 2022, 4:16:03 PM7/29/22
to fidl-dev, Suraj Malhotra, fidl-dev, Ian McKellar
On Thursday, July 28, 2022 at 3:00:32 PM UTC-7 Suraj Malhotra wrote:
Really happy to see this. Does this announcement mean that HLCPP usage is defacto deprecated (at least in tree)? Are there any plans to limit new usages via an allow list?

+ian...@google.com is planning to circulate an RFC to discuss these plans.

Ian McKellar

unread,
Jul 29, 2022, 4:26:43 PM7/29/22
to Yifei Teng, fidl-dev, Suraj Malhotra
On Fri, Jul 29, 2022 at 1:16 PM Yifei Teng <yif...@google.com> wrote:


On Thursday, July 28, 2022 at 3:00:32 PM UTC-7 Suraj Malhotra wrote:
Really happy to see this. Does this announcement mean that HLCPP usage is defacto deprecated (at least in tree)? Are there any plans to limit new usages via an allow list?

+ian...@google.com is planning to circulate an RFC to discuss these plans.

New draft RFC just dropped, like a Beyonce album: https://fxrev.dev/705622 

It's not widely circulated yet, but if you're interested, that's my current thinking

Ian
Reply all
Reply to author
Forward
0 new messages