Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
  • abdsaber000/vlc
  • falbrechtskirchinger/vlc
  • b.sullender/vlc
  • hulxv/vlc
  • zyad-ayad/vlc
408 results
Show changes
Commits on Source (5)
  • Alexandre Janniaux's avatar
    vlcrs-macros: rust-format module.rs code · 543b8897
    Alexandre Janniaux authored and François Cartegnie's avatar François Cartegnie committed
    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.
    543b8897
  • Alexandre Janniaux's avatar
    module.rs: use separate variable for version · d215c5cc
    Alexandre Janniaux authored and François Cartegnie's avatar François Cartegnie committed
    Using a separate variable for version allows matching the name of the C
    define, ensuring grep would highlight both while making it clearer that
    both needs to be updated. It also brings the benefit of removing the
    null-character from the string itself as it can now be directly
    concatenated when the code is generated, which ensures a future update
    will not break the version by forgetting the null-character.
    d215c5cc
  • Alexandre Janniaux's avatar
    module_default: add test for version · 22250933
    Alexandre Janniaux authored and François Cartegnie's avatar François Cartegnie committed
    Check that the version symbol is available and returns the correct
    C-string value.
    22250933
  • Alexandre Janniaux's avatar
    vlcrs-macros: add vlc_static_plugins #[cfg] · 8e3b6a8a
    Alexandre Janniaux authored and François Cartegnie's avatar François Cartegnie committed
    The vlc_static_plugins #[cfg] will be used to enforce suffixed
    vlc_entry_* functions naming, just like it is done in the plugin system
    when HAVE_DYNAMIC_PLUGINS is false, so that the modules generated from
    the rust buildsystem can also be linked into a static bundle of plugins.
    
    Features were considered in the first iteration of the design, since
    they can allow crates using vlcrs-macros to require the static
    entrypoint generator from the Cargo.toml file directly, but features are
    supposed to be used additively and not behaviour-changing so that it
    doesn't matter if a dependency is using the crate with extra-features
    when it doesn't require so.
    
    The additive design would have required to expose both the static_plugin
    feature and the dynamic_plugin feature, while allowing both to be
    enabled at the same time if needed, which meant generating two
    entrypoints on module!{} call.
    
    Note that #[cfg(vlc_static_plugins)] is checked at the compile time of
    the module being built, and not the compile time of the vlcrs-macros
    proc-macro crate since the cfg would not be forwarded to the crate
    otherwise without a proper build.rs file. Both variant are thus
    generated with proper #[cfg()] in the output of the module!{} macro.
    8e3b6a8a
  • Alexandre Janniaux's avatar
    include: vlc_plugin: notice Rust file for plugin version · 57f26370
    Alexandre Janniaux authored and François Cartegnie's avatar François Cartegnie committed
    57f26370
......@@ -217,7 +217,10 @@ enum vlc_config_subcat
};
/**
* Current plugin ABI version
* Current plugin ABI version.
*
* \note This must be synchronized with the values from:
* - src/rust/vlcrs-macros/module.rs
*/
#define VLC_API_VERSION_STRING "4.0.6"
......
......@@ -7,6 +7,9 @@ license.workspace = true
[lib]
proc-macro = true
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(vlc_static_plugins)'] }
[dependencies]
vlcrs-plugin = { path = "../vlcrs-plugin" }
quote = "1.0"
......
//! Module macros implementation
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use proc_macro2::{Span, 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,
};
const VLC_API_VERSION_STRING: &str = "4.0.6";
struct SectionInfo {
name: LitStr,
description: Option<LitStr>,
......@@ -161,7 +163,7 @@ impl Parse for ModuleInfo {
}
"submodules" => {
input.parse::<Token![:]>()?;
let inner;
bracketed!(inner in input);
let parsed_submodules = inner.parse_terminated(SubmoduleInfo::parse)?;
......@@ -710,8 +712,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)
......@@ -722,8 +723,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" {
......@@ -897,49 +897,66 @@ 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
}
)
......@@ -947,28 +964,55 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
{
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
}
}
fn vlc_symbol(symbol_name: &str, module_name: Option<&str>) -> Ident {
if let Some(module_name) = module_name {
Ident::new(
&format!("{}__{}", symbol_name, module_name),
Span::call_site(),
)
} else {
Ident::new(symbol_name, Span::call_site())
}
}
fn vlc_entry_api_version(module_suffix: Option<&str>) -> TokenStream2 {
let symbol = vlc_symbol("vlc_entry_api_version", module_suffix);
quote! {
#[no_mangle]
#[doc(hidden)]
extern "C" fn #symbol() -> *const u8 {
concat!(#VLC_API_VERSION_STRING, "\0").as_ptr()
}
}
}
#vlc_entry_config_subcategory
#vlc_entry_config_params
fn vlc_entry_copyright(module_suffix: Option<&str>) -> TokenStream2 {
let symbol = vlc_symbol("vlc_entry_copyright", module_suffix);
quote! {
#[no_mangle]
#[doc(hidden)]
extern "C" fn #symbol() -> *const u8 {
::vlcrs_plugin::VLC_COPYRIGHT_VIDEOLAN.as_ptr()
}
}
}
fn vlc_entry_license(module_suffix: Option<&str>) -> TokenStream2 {
let symbol = vlc_symbol("vlc_entry_license", module_suffix);
quote! {
#[no_mangle]
#[doc(hidden)]
extern "C" fn #symbol() -> *const u8 {
::vlcrs_plugin::VLC_LICENSE_LGPL_2_1_PLUS.as_ptr()
}
}
}
pub fn module(input: TokenStream) -> TokenStream {
......@@ -976,8 +1020,10 @@ pub fn module(input: TokenStream) -> TokenStream {
// TODO: Improve this with some kind environment variable passed by the build system
// like what is done for the C side.
let name = format!("{}-rs", module_info.type_.to_string().to_lowercase());
let module_suffix = module_info.type_.to_string().to_lowercase();
let name = format!("{}-rs", module_suffix);
let name_len = name.len() + 1;
let module_suffix = module_suffix + "_rs";
let name_with_nul = tt_c_str!(module_info.type_.span() => name);
......@@ -988,33 +1034,19 @@ pub fn module(input: TokenStream) -> TokenStream {
pub static vlc_module_name: &[u8; #name_len] = #name_with_nul;
};
// Copied from #define VLC_API_VERSION_STRING in include/vlc_plugin.h
let entry_api_version = quote! {
#[no_mangle]
#[doc(hidden)]
extern "C" fn vlc_entry_api_version() -> *const u8 {
b"4.0.6\0".as_ptr()
}
};
let entry_api_version = vlc_entry_api_version(None);
let entry_copyright = vlc_entry_copyright(None);
let entry_license = vlc_entry_license(None);
let entry_copyright = quote! {
#[no_mangle]
#[doc(hidden)]
extern "C" fn vlc_entry_copyright() -> *const u8 {
::vlcrs_plugin::VLC_COPYRIGHT_VIDEOLAN.as_ptr()
}
};
let entry_license = quote! {
#[no_mangle]
#[doc(hidden)]
extern "C" fn vlc_entry_license() -> *const u8 {
::vlcrs_plugin::VLC_LICENSE_LGPL_2_1_PLUS.as_ptr()
}
};
let entry_api_version_module_name = vlc_entry_api_version(Some(&module_suffix));
let entry_copyright_module_name = vlc_entry_copyright(Some(&module_suffix));
let entry_license_module_name = vlc_entry_license(Some(&module_suffix));
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;
......@@ -1065,51 +1097,80 @@ pub fn module(input: TokenStream) -> TokenStream {
}
});
let module_entry = quote! {
#[no_mangle]
#[doc(hidden)]
extern "C" fn vlc_entry(
vlc_set: ::vlcrs_plugin::sys::vlc_set_cb,
opaque: *mut ::std::ffi::c_void,
) -> i32 {
use vlcrs_plugin::ModuleProtocol;
let mut module: *mut ::vlcrs_plugin::module_t = ::std::ptr::null_mut();
let mut config: *mut ::vlcrs_plugin::vlc_param = ::std::ptr::null_mut();
let vlc_entry = |module_suffix: Option<&str>| {
let symbol = vlc_symbol("vlc_entry", module_suffix);
quote! {
#[no_mangle]
#[doc(hidden)]
extern "C" fn #symbol(
vlc_set: ::vlcrs_plugin::sys::vlc_set_cb,
opaque: *mut ::std::ffi::c_void,
) -> i32 {
use vlcrs_plugin::ModuleProtocol;
let mut module: *mut ::vlcrs_plugin::module_t = ::std::ptr::null_mut();
let mut config: *mut ::vlcrs_plugin::vlc_param = ::std::ptr::null_mut();
if unsafe {
vlc_set(
opaque,
::std::ptr::null_mut(),
::vlcrs_plugin::ModuleProperties::MODULE_CREATE as _,
&mut module as *mut *mut ::vlcrs_plugin::module_t,
)
} != 0
{
return -1;
}
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_NAME as _,
#name_with_nul,
)
} != 0
{
return -1;
if unsafe {
vlc_set(
opaque,
::std::ptr::null_mut(),
::vlcrs_plugin::ModuleProperties::MODULE_CREATE as _,
&mut module as *mut *mut ::vlcrs_plugin::module_t,
)
} != 0
{
return -1;
}
if unsafe {
vlc_set(
opaque,
module as _,
::vlcrs_plugin::ModuleProperties::MODULE_NAME as _,
#name_with_nul,
)
} != 0
{
return -1;
}
#module_entry_configs
#submodules_entry
0
}
#module_entry_configs
#submodules_entry
0
}
};
let module_entry_module_name = vlc_entry(Some(&module_suffix));
let module_entry = vlc_entry(None);
let cfg_static = quote!{ #[cfg(vlc_static_plugins)] };
let cfg_not_static = quote!{ #[cfg(not(vlc_static_plugins))] };
let expanded = quote! {
#type_params
#cfg_static
#entry_api_version_module_name
#cfg_static
#entry_license_module_name
#cfg_static
#entry_copyright_module_name
#cfg_static
#module_entry_module_name
#cfg_not_static
#entry_api_version
#cfg_not_static
#entry_license
#cfg_not_static
#entry_copyright
#module_name
#cfg_not_static
#module_entry
};
TokenStream::from(expanded)
......
......@@ -12,7 +12,7 @@ use common::TestContext;
use vlcrs_macros::module;
use std::ffi::c_int;
use std::ffi::{c_int, CStr};
use vlcrs_plugin::{ModuleProtocol,vlc_activate};
unsafe extern "C"
......@@ -71,6 +71,9 @@ module! {
#[test]
fn test_module_load_default_deactivate()
{
let version = unsafe{ CStr::from_ptr(vlc_entry_api_version() as *const i8) };
assert_eq!(version, c"4.0.6");
use vlcrs_plugin::ModuleProperties;
let mut context = TestContext::<vlc_activate> {
command_cursor: 0,
......