KDAB / cxx-qt

Safe interop between Rust and Qt
https://kdab.github.io/cxx-qt/book/
1.05k stars 75 forks source link

Bring back auto camel case but explicit this time #1105

Closed ahayzen-kdab closed 1 hour ago

ahayzen-kdab commented 1 week ago

Instead of implicit auto camel conversion make it explicit and potentially per extern block?

This could look like at a bridge level or extern block level.

#[cxx_qt::bridge(auto_camel_case)]
mod ffi {
  unsafe extern "C++Qt" {
    fn my_function(&self: MyQObject);  // would be myFunction in C++
  }
}

Or

#[cxx_qt::bridge]
mod ffi {
  #[auto_camel_case]
  unsafe extern "C++Qt" {
    fn my_function(&self: MyQObject);  // would be myFunction in C++
  }
}
ahayzen-kdab commented 1 week ago

The name could also include cxx in it such as cxx_auto_camel, as the way this works is if there is no cxx_name specified it will camel case the effective rust name.

LeonMatthesKDAB commented 1 week ago

Hm, as we (currently) don't plan to do case conversion on CXX types/blocks, I prefer the per-block style, as it explicitly covers a given scope.

Additionaly, I would call the attribute #[auto_casing], as we are also converting to snake_case, in extern "C++Qt". (and would leave the door open to specifying your own casing (e.g.: #[auto_casing="PascalCase"] or whatever.

BenFordTytherington commented 1 hour ago

Implemented and merged in #1108