Open Bug 1850592 Opened 2 years ago Updated 2 years ago

Autogenerate C++ bindings for authrs_bridge

Categories

(Core :: DOM: Web Authentication, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: jschanck, Unassigned)

Details

Attachments

(1 file)

We should use cbindgen to create bindings for authrs_transport_constructor and authrs_webauthn_att_obj_constructor. There's a very minor obstacle to doing this at the moment. That is

  1. the rust side defines its out parameters as *mut *const T,
  2. cbindgen produces a header with out params of type const T**, and
  3. the C++ side uses getterAddRefs which converts to T **.

This results in a compile error:
candidate function not viable: no known conversion from 'nsGetterAddRefs<T>' to 'const T **' .

If that's the only blocker, we could define the rust function to use *mut *mut T, right? It should automatically coerce to *mut *const T if needed.

The compiler won't automatically coerce the inner pointer type, but using *mut *mut T and manually coercing is certainly one solution.

FWIW, there are a number of other instances of this pattern, and most of those could benefit from automatic binding generation.

An even better alternative would be to make getterAddrefs coerce to const T**, I guess.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: