[vlc-commits] [Git][videolan/vlc][master] 4 commits: vlcrs-core: add the vlcrs-core crate
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Oct 3 09:16:38 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
255e3bc6 by Loïc at 2024-10-03T09:00:42+00:00
vlcrs-core: add the vlcrs-core crate
vlcrs-core is the crate that will be responsible for having the safe
abstractions around the unsafe C functions and definitions.
- - - - -
2be4b880 by Vikram Kangotra at 2024-10-03T09:00:42+00:00
vlcrs-core: add vlcrs-core to workspace
- - - - -
b3940e51 by Vikram Kangotra at 2024-10-03T09:00:42+00:00
rust: add vlc_object_t abstraction
- - - - -
9285760f by Vikram Kangotra at 2024-10-03T09:00:42+00:00
rust: vlcrs-plugin: use Object from vlcrs-core
- - - - -
10 changed files:
- src/rust/Cargo.toml
- + src/rust/vlcrs-core/Cargo.toml
- + src/rust/vlcrs-core/src/lib.rs
- + src/rust/vlcrs-core/src/object/mod.rs
- + src/rust/vlcrs-core/src/object/sys.rs
- src/rust/vlcrs-macros/Cargo.toml
- src/rust/vlcrs-macros/tests/module.rs
- src/rust/vlcrs-macros/tests/module_default.rs
- src/rust/vlcrs-plugin/Cargo.toml
- src/rust/vlcrs-plugin/src/lib.rs
Changes:
=====================================
src/rust/Cargo.toml
=====================================
@@ -1,5 +1,6 @@
[workspace]
members = [
+ "vlcrs-core",
"vlcrs-macros",
"vlcrs-messages",
"vlcrs-plugin",
=====================================
src/rust/vlcrs-core/Cargo.toml
=====================================
@@ -0,0 +1,7 @@
+[package]
+name = "vlcrs-core"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+vlcrs-messages = { path = "../vlcrs-messages" }
=====================================
src/rust/vlcrs-core/src/lib.rs
=====================================
@@ -0,0 +1,11 @@
+#![deny(unsafe_op_in_unsafe_fn)]
+
+//! The `vlcrs-core` crate.
+//!
+//! This crate contains the vlc core APIs that have been ported or
+//! wrapped for usage by Rust code in the modules and is shared by all of them.
+//!
+//! If you need a vlc core C API that is not ported or wrapped yet here,
+//! then do so first instead of bypassing this crate.
+
+pub mod object;
=====================================
src/rust/vlcrs-core/src/object/mod.rs
=====================================
@@ -0,0 +1,19 @@
+mod sys;
+
+use sys::ObjectInternalData;
+use vlcrs_messages::Logger;
+
+#[repr(C)]
+pub struct Object {
+ logger: Option<Logger>,
+ internal_data: ObjectInternalData,
+ no_interact: bool,
+ force: bool,
+}
+
+impl Object {
+
+ pub fn logger(&self) -> Option<&Logger> {
+ self.logger.as_ref()
+ }
+}
=====================================
src/rust/vlcrs-core/src/object/sys.rs
=====================================
@@ -0,0 +1,18 @@
+use std::ptr::NonNull;
+
+#[repr(C)]
+pub(super) struct ObjectInternals {
+ _unused: [u8; 0],
+}
+
+#[repr(C)]
+pub(super) struct ObjectMarker {
+ _unused: [u8; 0],
+}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub(super) union ObjectInternalData {
+ pub internals: Option<NonNull<ObjectInternals>>,
+ pub marker: Option<NonNull<ObjectMarker>>,
+}
=====================================
src/rust/vlcrs-macros/Cargo.toml
=====================================
@@ -11,6 +11,7 @@ proc-macro = true
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(vlc_static_plugins)'] }
[dependencies]
+vlcrs-core = { path = "../vlcrs-core" }
vlcrs-plugin = { path = "../vlcrs-plugin" }
quote = "1.0"
syn = { version = "1.0", features = ["full"] }
=====================================
src/rust/vlcrs-macros/tests/module.rs
=====================================
@@ -15,14 +15,16 @@ use std::ffi::c_int;
use vlcrs_plugin::{vlc_activate, vlc_deactivate};
+use vlcrs_core::object::Object;
+
unsafe extern "C"
-fn activate_test<T: SpecificCapabilityModule>(_obj: *mut vlcrs_plugin::vlc_object_t) -> c_int
+fn activate_test<T: SpecificCapabilityModule>(_obj: *mut Object) -> c_int
{
0
}
unsafe extern "C"
-fn deactivate_test<T: SpecificCapabilityModule>(_obj: *mut vlcrs_plugin::vlc_object_t)
+fn deactivate_test<T: SpecificCapabilityModule>(_obj: *mut Object)
{}
use vlcrs_plugin::ModuleProtocol;
=====================================
src/rust/vlcrs-macros/tests/module_default.rs
=====================================
@@ -15,8 +15,10 @@ use vlcrs_macros::module;
use std::ffi::{c_int, CStr};
use vlcrs_plugin::{ModuleProtocol,vlc_activate};
+use vlcrs_core::object::Object;
+
unsafe extern "C"
-fn activate_filter(_obj: *mut vlcrs_plugin::vlc_object_t) -> c_int
+fn activate_filter(_obj: *mut Object) -> c_int
{
0
}
=====================================
src/rust/vlcrs-plugin/Cargo.toml
=====================================
@@ -5,3 +5,4 @@ version.workspace = true
license.workspace = true
[dependencies]
+vlcrs-core = { path = "../vlcrs-core" }
=====================================
src/rust/vlcrs-plugin/src/lib.rs
=====================================
@@ -3,6 +3,8 @@
pub mod sys;
+use vlcrs_core::object::Object;
+
pub const VLC_COPYRIGHT_VIDEOLAN : &str = r#"
\x43\x6f\x70\x79\x72\x69\x67\x68\x74\x20\x28\x43\x29\x20\x74\x68
\x65\x20\x56\x69\x64\x65\x6f\x4c\x41\x4e\x20\x56\x4c\x43\x20\x6d
@@ -19,7 +21,6 @@ pub const VLC_LICENSE_LGPL_2_1_PLUS : &str = r#"
#[allow(non_camel_case_types)]
#[allow(unused)]
extern {
- pub type vlc_object_t;
pub type module_t;
pub type vlc_param;
}
@@ -196,9 +197,9 @@ impl TryFrom<i32> for ModuleProperties {
use std::ffi::c_int;
#[allow(non_camel_case_types)]
-pub type vlc_activate = unsafe extern "C" fn(*mut vlc_object_t) -> c_int;
+pub type vlc_activate = unsafe extern "C" fn(*mut Object) -> c_int;
#[allow(non_camel_case_types)]
-pub type vlc_deactivate = unsafe extern "C" fn(*mut vlc_object_t);
+pub type vlc_deactivate = unsafe extern "C" fn(*mut Object);
///
/// Exposes the activation and deactivation functions for modules.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1fdf9c9f7c7643b6b87084b170c1b68390ec27bd...9285760f0c260679262d3976d833b63f2d66e33e
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1fdf9c9f7c7643b6b87084b170c1b68390ec27bd...9285760f0c260679262d3976d833b63f2d66e33e
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list