mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-29 05:14:48 +00:00
Split corelib::abi::sharedarray into corelib::sharedarray and corelib::sharedarray::ffi
This commit is contained in:
parent
3ad7a55038
commit
f79b80f1e6
4 changed files with 28 additions and 23 deletions
|
@ -70,7 +70,7 @@ fn main() {
|
|||
|
||||
cbindgen::Builder::new()
|
||||
.with_config(config.clone())
|
||||
.with_src(crate_dir.join("abi/sharedarray.rs"))
|
||||
.with_src(crate_dir.join("sharedarray.rs"))
|
||||
.with_after_include("namespace sixtyfps { template<typename T> struct SharedArray; }")
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
|
|
|
@ -120,7 +120,7 @@ pub enum Resource {
|
|||
EmbeddedData(super::slice::Slice<'static, u8>),
|
||||
/// Raw ARGB
|
||||
#[allow(missing_docs)]
|
||||
EmbeddedRgbaImage { width: u32, height: u32, data: super::abi::sharedarray::SharedArray<u8> },
|
||||
EmbeddedRgbaImage { width: u32, height: u32, data: super::sharedarray::SharedArray<u8> },
|
||||
}
|
||||
|
||||
impl Default for Resource {
|
||||
|
|
|
@ -28,11 +28,11 @@ pub mod abi {
|
|||
#![allow(unsafe_code)]
|
||||
pub mod datastructures;
|
||||
pub mod model;
|
||||
pub mod sharedarray;
|
||||
}
|
||||
|
||||
pub mod items;
|
||||
pub mod properties;
|
||||
pub mod sharedarray;
|
||||
pub mod signals;
|
||||
pub mod string;
|
||||
|
||||
|
@ -40,7 +40,7 @@ pub mod string;
|
|||
pub use string::SharedString;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use abi::sharedarray::SharedArray;
|
||||
pub use sharedarray::SharedArray;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use graphics::Resource;
|
||||
|
@ -74,7 +74,7 @@ pub mod tests;
|
|||
pub fn use_modules() -> usize {
|
||||
tests::sixtyfps_mock_elapsed_time as usize
|
||||
+ signals::ffi::sixtyfps_signal_init as usize
|
||||
+ abi::sharedarray::sixtyfps_shared_array_drop as usize
|
||||
+ sharedarray::ffi::sixtyfps_shared_array_drop as usize
|
||||
+ layout::solve_grid_layout as usize
|
||||
+ item_tree::ffi::sixtyfps_visit_item_tree as usize
|
||||
+ graphics::ffi::sixtyfps_new_path_elements as usize
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//! module for the SharedArray and related things
|
||||
#![allow(unsafe_code)]
|
||||
use core::mem::MaybeUninit;
|
||||
use std::{fmt::Debug, fmt::Display, ops::Deref};
|
||||
use triomphe::{Arc, HeaderWithLength, ThinArc};
|
||||
|
@ -169,24 +170,28 @@ fn simple_test() {
|
|||
assert_ne!(def, x);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
/// This function is used for the low-level C++ interface to allocate the backing vector for an empty shared array.
|
||||
pub unsafe extern "C" fn sixtyfps_shared_array_new_null(out: *mut SharedArray<u8>) {
|
||||
core::ptr::write(out, SharedArray::<u8>::default());
|
||||
}
|
||||
pub(crate) mod ffi {
|
||||
use super::*;
|
||||
|
||||
#[no_mangle]
|
||||
/// This function is used for the low-level C++ interface to clone a shared array by increasing its reference count.
|
||||
pub unsafe extern "C" fn sixtyfps_shared_array_clone(
|
||||
out: *mut SharedArray<u8>,
|
||||
source: &SharedArray<u8>,
|
||||
) {
|
||||
core::ptr::write(out, source.clone());
|
||||
}
|
||||
#[no_mangle]
|
||||
/// This function is used for the low-level C++ interface to allocate the backing vector for an empty shared array.
|
||||
pub unsafe extern "C" fn sixtyfps_shared_array_new_null(out: *mut SharedArray<u8>) {
|
||||
core::ptr::write(out, SharedArray::<u8>::default());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
/// This function is used for the low-level C++ interface to decrease the reference count of a shared array.
|
||||
pub unsafe extern "C" fn sixtyfps_shared_array_drop(out: *mut SharedArray<u8>) {
|
||||
// ?? This won't call drop on the right type...
|
||||
core::ptr::read(out);
|
||||
#[no_mangle]
|
||||
/// This function is used for the low-level C++ interface to clone a shared array by increasing its reference count.
|
||||
pub unsafe extern "C" fn sixtyfps_shared_array_clone(
|
||||
out: *mut SharedArray<u8>,
|
||||
source: &SharedArray<u8>,
|
||||
) {
|
||||
core::ptr::write(out, source.clone());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
/// This function is used for the low-level C++ interface to decrease the reference count of a shared array.
|
||||
pub unsafe extern "C" fn sixtyfps_shared_array_drop(out: *mut SharedArray<u8>) {
|
||||
// ?? This won't call drop on the right type...
|
||||
core::ptr::read(out);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue