Skip to content

Commit

Permalink
refactor: Pluralize SignalNames&SignalHelperNames
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonMatthesKDAB committed Jun 4, 2024
1 parent d9b362f commit 309190a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions crates/cxx-qt-gen/src/generator/cpp/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
cpp::{fragment::CppFragment, qobject::GeneratedCppQObjectBlocks},
naming::{
qobject::QObjectNames,
signals::{QSignalHelperName, QSignalName},
signals::{QSignalHelperNames, QSignalNames},
},
},
naming::{cpp::syn_type_to_cpp_type, Name, TypeNames},
Expand Down Expand Up @@ -94,8 +94,8 @@ pub fn generate_cpp_signal(
let qobject_ident_namespaced = qobject_name.cxx_qualified();

// Prepare the idents
let idents = QSignalName::from(signal);
let idents_helper = QSignalHelperName::new(&idents, qobject_name)?;
let idents = QSignalNames::from(signal);
let idents_helper = QSignalHelperNames::new(&idents, qobject_name)?;

let signal_ident = idents.name.cxx_unqualified();
let free_connect_ident_cpp = idents_helper.connect_name.cxx_unqualified();
Expand Down
14 changes: 7 additions & 7 deletions crates/cxx-qt-gen/src/generator/naming/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use quote::format_ident;
use syn::{Ident, Result};

/// Names for parts of a Q_SIGNAL
pub struct QSignalName {
pub struct QSignalNames {
pub name: Name,
pub connect_name: Name,
pub on_name: Ident,
}

impl From<&ParsedSignal> for QSignalName {
impl From<&ParsedSignal> for QSignalNames {
fn from(signal: &ParsedSignal) -> Self {
Self {
name: signal.name.clone(),
Expand All @@ -36,7 +36,7 @@ fn on_from_signal(ident: &Ident) -> Ident {
format_ident!("on_{}", ident.to_string().to_case(Case::Snake))
}

pub struct QSignalHelperName {
pub struct QSignalHelperNames {
pub connect_name: Name,
pub function_call: Ident,
pub function_drop: Ident,
Expand All @@ -47,8 +47,8 @@ pub struct QSignalHelperName {
pub struct_param: Ident,
}

impl QSignalHelperName {
pub fn new(idents: &QSignalName, qobject_name: &Name) -> Result<Self> {
impl QSignalHelperNames {
pub fn new(idents: &QSignalNames, qobject_name: &Name) -> Result<Self> {
let signal_ident = &idents.name.cxx_unqualified();
let qobject_ident = qobject_name.rust_unqualified().to_string();
let handler_alias = format_ident!("{qobject_ident}CxxQtSignalHandler{signal_ident}");
Expand Down Expand Up @@ -120,7 +120,7 @@ mod tests {
private: false,
};

let names = QSignalName::from(&qsignal);
let names = QSignalNames::from(&qsignal);
assert_eq!(names.name.cxx_unqualified(), "dataChanged");
assert_eq!(
names.name.rust_unqualified(),
Expand Down Expand Up @@ -150,7 +150,7 @@ mod tests {
private: false,
};

let names = QSignalName::from(&qsignal);
let names = QSignalNames::from(&qsignal);
assert_eq!(names.name.cxx_unqualified(), "baseName");
assert_eq!(
names.name.rust_unqualified(),
Expand Down
8 changes: 4 additions & 4 deletions crates/cxx-qt-gen/src/generator/rust/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
generator::{
naming::{
qobject::QObjectNames,
signals::{QSignalHelperName, QSignalName},
signals::{QSignalHelperNames, QSignalNames},
},
rust::fragment::{GeneratedRustFragment, RustFragmentPair},
},
Expand All @@ -24,8 +24,8 @@ pub fn generate_rust_signal(
type_names: &TypeNames,
module_ident: &Ident,
) -> Result<GeneratedRustFragment> {
let idents = QSignalName::from(signal);
let idents_helper = QSignalHelperName::new(&idents, qobject_name)?;
let idents = QSignalNames::from(signal);
let idents_helper = QSignalHelperNames::new(&idents, qobject_name)?;

let qobject_name_rust = qobject_name.rust_unqualified();

Expand Down Expand Up @@ -220,7 +220,7 @@ pub fn generate_rust_signals(
if attribute_find_path(&signal.method.attrs, &["cxx_name"]).is_none()
&& attribute_find_path(&signal.method.attrs, &["rust_name"]).is_none()
{
let idents = QSignalName::from(&signal);
let idents = QSignalNames::from(&signal);
let signal_name_cpp = idents.name.cxx_unqualified();
signal
.method
Expand Down

0 comments on commit 309190a

Please sign in to comment.