Skip to content

Commit

Permalink
vlcrs-macros: rust-format module.rs code
Browse files Browse the repository at this point in the history
The module.rs file had a lot of additional intendation and other points
that were automatically changed when re-formatting. Apply those
formatting options to avoid it changing too much code each time it is
called.
  • Loading branch information
alexandre-janniaux authored and fcartegnie committed Sep 2, 2024
1 parent 0d68338 commit 543b889
Showing 1 changed file with 68 additions and 67 deletions.
135 changes: 68 additions & 67 deletions src/rust/vlcrs-macros/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::{quote, quote_spanned, ToTokens};
use syn::{
braced, bracketed, parenthesized, parse::Parse, parse_macro_input,
punctuated::Punctuated, spanned::Spanned, Attribute, Error, ExprRange,
Ident, Lit, LitByteStr, LitInt, LitStr, MetaNameValue, RangeLimits, Token
braced, bracketed, parenthesized, parse::Parse, parse_macro_input, punctuated::Punctuated,
spanned::Spanned, Attribute, Error, ExprRange, Ident, Lit, LitByteStr, LitInt, LitStr,
MetaNameValue, RangeLimits, Token,
};

struct SectionInfo {
Expand Down Expand Up @@ -161,7 +161,7 @@ impl Parse for ModuleInfo {
}
"submodules" => {
input.parse::<Token![:]>()?;

let inner;
bracketed!(inner in input);
let parsed_submodules = inner.parse_terminated(SubmoduleInfo::parse)?;
Expand Down Expand Up @@ -710,8 +710,7 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
::std::convert::Into::<::std::ffi::c_double>::into(#default_)
}
};
let item_type =
quote! { ::vlcrs_plugin::ConfigModule::ITEM_FLOAT };
let item_type = quote! { ::vlcrs_plugin::ConfigModule::ITEM_FLOAT };
let range_type = Some(quote! { ::std::ffi::c_double });

(value, item_type, range_type)
Expand All @@ -722,8 +721,7 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
::std::convert::Into::<i64>::into(#default_)
}
};
let item_type =
quote! { ::vlcrs_plugin::ConfigModule::ITEM_BOOL };
let item_type = quote! { ::vlcrs_plugin::ConfigModule::ITEM_BOOL };

(value, item_type, None)
} else if param.type_ == "str" {
Expand Down Expand Up @@ -897,78 +895,78 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
let module_close_with_nul = tt_c_str!(type_.span() => module_close);

quote! {
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_CAPABILITY as _,
#capability_with_nul,
)
} != 0 {
return -1;
}
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_SCORE as _,
::std::convert::Into::<i32>::into(#score),
)
} != 0 {
return -1;
}
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_CAPABILITY as _,
#capability_with_nul,
)
} != 0 {
return -1;
}
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_SCORE as _,
::std::convert::Into::<i32>::into(#score),
)
} != 0 {
return -1;
}

if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_DESCRIPTION as _,
#description_with_nul,
)
} != 0
{
return -1;
}
#module_entry_help
#module_entry_shortname
#module_entry_shortcuts
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_CB_OPEN as _,
#module_open_with_nul,
unsafe {
<#loader as ModuleProtocol<#type_>>::activate_function()
as *mut std::ffi::c_void
}
)
} != 0
{
return -1;
}

if <#loader as ModuleProtocol<#type_>>::deactivate_function() != None {
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_DESCRIPTION as _,
#description_with_nul,
)
} != 0
{
return -1;
}
#module_entry_help
#module_entry_shortname
#module_entry_shortcuts
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_CB_OPEN as _,
#module_open_with_nul,
::vlcrs_plugin::ModuleProperties::MODULE_CB_CLOSE as _,
#module_close_with_nul,
unsafe {
<#loader as ModuleProtocol<#type_>>::activate_function()
<#loader as ModuleProtocol<#type_>>::deactivate_function().unwrap()
as *mut std::ffi::c_void
}
)
} != 0
{
return -1;
}

if <#loader as ModuleProtocol<#type_>>::deactivate_function() != None {
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_CB_CLOSE as _,
#module_close_with_nul,
unsafe {
<#loader as ModuleProtocol<#type_>>::deactivate_function().unwrap()
as *mut std::ffi::c_void
}
)
} != 0
{
return -1;
}
}

#vlc_entry_config_subcategory
#vlc_entry_config_params
}

#vlc_entry_config_subcategory
#vlc_entry_config_params
}
}

pub fn module(input: TokenStream) -> TokenStream {
Expand Down Expand Up @@ -1014,7 +1012,10 @@ pub fn module(input: TokenStream) -> TokenStream {
};

let type_params = module_info.params.as_ref().map(|params| {
let struct_name = Ident::new(&format!("{}Args", module_info.type_), module_info.type_.span());
let struct_name = Ident::new(
&format!("{}Args", module_info.type_),
module_info.type_.span(),
);

let params_def = params.params.iter().map(|param| {
let rust_name = &param.name;
Expand Down

0 comments on commit 543b889

Please sign in to comment.