#1303

Generate container element trait implementations inside bridge blocks

Openjnboothopened 1y ago

It would be convenient if instead of needing all those generate.sh scripts, you could do something like this:

#[cxx_qt::bridge]
mod ffi {
  extern "C++" {
    type MyType = super::MyType;
  }

  impl QList<MyType> {
    type TypeId = type_id!("QList_MyType");
  }
}

Then it would generate the C++ and Rust code automatically. Note that I'm using the syntax impl QList<MyType> rather than impl QListElement for MyType to match the style of cxx's shim trait impls. I've been playing around with cxx-qt-gen and would be interested in taking a stab at this, if other people think it would be a good idea.

Activity

2
fredizzimo1y ago

As a user of the library, I would love to see this. I'm trying to generate bindings for the kwin scripting api as a library in the style of cxx-qt-lib.

For containers I'm currently hacking it by copying the generate script from here and modifying it, but that's far from ideal. It would be nice to be able to share the code another way.

Edit: Actually I think my approach still doesn't work. impl_qlist_element which is also required is not public.

fredizzimo1y ago

As a user of the library, I would love to see this. I'm trying to generate bindings for the kwin scripting api as a library in the style of cxx-qt-lib.

For containers I'm currently hacking it by copying the generate script from here and modifying it, but that's far from ideal. It would be nice to be able to share the code another way.

Edit: Actually I think my approach still doesn't work. impl_qlist_element which is also required is not public.