/* generated by rust_qt_binding_generator */ use libc::{c_char, c_ushort, c_int}; use std::slice; use std::char::decode_utf16; use std::sync::Arc; use std::sync::atomic::{AtomicPtr, Ordering}; use std::ptr::null; use implementation::*; #[repr(C)] pub struct COption { data: T, some: bool, } impl COption { #![allow(dead_code)] fn into(self) -> Option { if self.some { Some(self.data) } else { None } } } impl From> for COption where T: Default, { fn from(t: Option) -> COption { if let Some(v) = t { COption { data: v, some: true, } } else { COption { data: T::default(), some: false, } } } } pub enum QString {} fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) { let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) }; let characters = decode_utf16(utf16.iter().cloned()) .map(|r| r.unwrap()); s.clear(); s.extend(characters); } pub enum QByteArray {} #[repr(C)] #[derive(PartialEq, Eq, Debug)] pub enum SortOrder { Ascending = 0, Descending = 1, } #[repr(C)] pub struct QModelIndex { row: c_int, internal_id: usize, } fn to_usize(n: c_int) -> usize { if n < 0 { panic!("Cannot cast {} to usize", n); } n as usize } fn to_c_int(n: usize) -> c_int { if n > c_int::max_value() as usize { panic!("Cannot cast {} to c_int", n); } n as c_int } pub struct DemoQObject {} pub struct DemoEmitter { qobject: Arc>, } unsafe impl Send for DemoEmitter {} impl DemoEmitter { /// Clone the emitter /// /// The emitter can only be cloned when it is mutable. The emitter calls /// into C++ code which may call into Rust again. If emmitting is possible /// from immutable structures, that might lead to access to a mutable /// reference. That is undefined behaviour and forbidden. pub fn clone(&mut self) -> DemoEmitter { DemoEmitter { qobject: self.qobject.clone(), } } fn clear(&self) { let n: *const DemoQObject = null(); self.qobject.store(n as *mut DemoQObject, Ordering::SeqCst); } } pub trait DemoTrait { fn new(emit: DemoEmitter, fibonacci: Fibonacci, fibonacci_list: FibonacciList, file_system_tree: FileSystemTree, processes: Processes, time_series: TimeSeries) -> Self; fn emit(&mut self) -> &mut DemoEmitter; fn fibonacci(&self) -> &Fibonacci; fn fibonacci_mut(&mut self) -> &mut Fibonacci; fn fibonacci_list(&self) -> &FibonacciList; fn fibonacci_list_mut(&mut self) -> &mut FibonacciList; fn file_system_tree(&self) -> &FileSystemTree; fn file_system_tree_mut(&mut self) -> &mut FileSystemTree; fn processes(&self) -> &Processes; fn processes_mut(&mut self) -> &mut Processes; fn time_series(&self) -> &TimeSeries; fn time_series_mut(&mut self) -> &mut TimeSeries; } #[no_mangle] pub extern "C" fn demo_new( demo: *mut DemoQObject, fibonacci: *mut FibonacciQObject, fibonacci_input_changed: fn(*mut FibonacciQObject), fibonacci_result_changed: fn(*mut FibonacciQObject), fibonacci_list: *mut FibonacciListQObject, fibonacci_list_new_data_ready: fn(*mut FibonacciListQObject), fibonacci_list_layout_about_to_be_changed: fn(*mut FibonacciListQObject), fibonacci_list_layout_changed: fn(*mut FibonacciListQObject), fibonacci_list_data_changed: fn(*mut FibonacciListQObject, usize, usize), fibonacci_list_begin_reset_model: fn(*mut FibonacciListQObject), fibonacci_list_end_reset_model: fn(*mut FibonacciListQObject), fibonacci_list_begin_insert_rows: fn(*mut FibonacciListQObject, usize, usize), fibonacci_list_end_insert_rows: fn(*mut FibonacciListQObject), fibonacci_list_begin_move_rows: fn(*mut FibonacciListQObject, usize, usize, usize), fibonacci_list_end_move_rows: fn(*mut FibonacciListQObject), fibonacci_list_begin_remove_rows: fn(*mut FibonacciListQObject, usize, usize), fibonacci_list_end_remove_rows: fn(*mut FibonacciListQObject), file_system_tree: *mut FileSystemTreeQObject, file_system_tree_path_changed: fn(*mut FileSystemTreeQObject), file_system_tree_new_data_ready: fn(*mut FileSystemTreeQObject, index: COption), file_system_tree_layout_about_to_be_changed: fn(*mut FileSystemTreeQObject), file_system_tree_layout_changed: fn(*mut FileSystemTreeQObject), file_system_tree_data_changed: fn(*mut FileSystemTreeQObject, usize, usize), file_system_tree_begin_reset_model: fn(*mut FileSystemTreeQObject), file_system_tree_end_reset_model: fn(*mut FileSystemTreeQObject), file_system_tree_begin_insert_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize), file_system_tree_end_insert_rows: fn(*mut FileSystemTreeQObject), file_system_tree_begin_move_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize, index: COption, usize), file_system_tree_end_move_rows: fn(*mut FileSystemTreeQObject), file_system_tree_begin_remove_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize), file_system_tree_end_remove_rows: fn(*mut FileSystemTreeQObject), processes: *mut ProcessesQObject, processes_active_changed: fn(*mut ProcessesQObject), processes_new_data_ready: fn(*mut ProcessesQObject, index: COption), processes_layout_about_to_be_changed: fn(*mut ProcessesQObject), processes_layout_changed: fn(*mut ProcessesQObject), processes_data_changed: fn(*mut ProcessesQObject, usize, usize), processes_begin_reset_model: fn(*mut ProcessesQObject), processes_end_reset_model: fn(*mut ProcessesQObject), processes_begin_insert_rows: fn(*mut ProcessesQObject, index: COption, usize, usize), processes_end_insert_rows: fn(*mut ProcessesQObject), processes_begin_move_rows: fn(*mut ProcessesQObject, index: COption, usize, usize, index: COption, usize), processes_end_move_rows: fn(*mut ProcessesQObject), processes_begin_remove_rows: fn(*mut ProcessesQObject, index: COption, usize, usize), processes_end_remove_rows: fn(*mut ProcessesQObject), time_series: *mut TimeSeriesQObject, time_series_new_data_ready: fn(*mut TimeSeriesQObject), time_series_layout_about_to_be_changed: fn(*mut TimeSeriesQObject), time_series_layout_changed: fn(*mut TimeSeriesQObject), time_series_data_changed: fn(*mut TimeSeriesQObject, usize, usize), time_series_begin_reset_model: fn(*mut TimeSeriesQObject), time_series_end_reset_model: fn(*mut TimeSeriesQObject), time_series_begin_insert_rows: fn(*mut TimeSeriesQObject, usize, usize), time_series_end_insert_rows: fn(*mut TimeSeriesQObject), time_series_begin_move_rows: fn(*mut TimeSeriesQObject, usize, usize, usize), time_series_end_move_rows: fn(*mut TimeSeriesQObject), time_series_begin_remove_rows: fn(*mut TimeSeriesQObject, usize, usize), time_series_end_remove_rows: fn(*mut TimeSeriesQObject), ) -> *mut Demo { let fibonacci_emit = FibonacciEmitter { qobject: Arc::new(AtomicPtr::new(fibonacci)), input_changed: fibonacci_input_changed, result_changed: fibonacci_result_changed, }; let d_fibonacci = Fibonacci::new(fibonacci_emit); let fibonacci_list_emit = FibonacciListEmitter { qobject: Arc::new(AtomicPtr::new(fibonacci_list)), new_data_ready: fibonacci_list_new_data_ready, }; let model = FibonacciListList { qobject: fibonacci_list, layout_about_to_be_changed: fibonacci_list_layout_about_to_be_changed, layout_changed: fibonacci_list_layout_changed, data_changed: fibonacci_list_data_changed, begin_reset_model: fibonacci_list_begin_reset_model, end_reset_model: fibonacci_list_end_reset_model, begin_insert_rows: fibonacci_list_begin_insert_rows, end_insert_rows: fibonacci_list_end_insert_rows, begin_move_rows: fibonacci_list_begin_move_rows, end_move_rows: fibonacci_list_end_move_rows, begin_remove_rows: fibonacci_list_begin_remove_rows, end_remove_rows: fibonacci_list_end_remove_rows, }; let d_fibonacci_list = FibonacciList::new(fibonacci_list_emit, model); let file_system_tree_emit = FileSystemTreeEmitter { qobject: Arc::new(AtomicPtr::new(file_system_tree)), path_changed: file_system_tree_path_changed, new_data_ready: file_system_tree_new_data_ready, }; let model = FileSystemTreeTree { qobject: file_system_tree, layout_about_to_be_changed: file_system_tree_layout_about_to_be_changed, layout_changed: file_system_tree_layout_changed, data_changed: file_system_tree_data_changed, begin_reset_model: file_system_tree_begin_reset_model, end_reset_model: file_system_tree_end_reset_model, begin_insert_rows: file_system_tree_begin_insert_rows, end_insert_rows: file_system_tree_end_insert_rows, begin_move_rows: file_system_tree_begin_move_rows, end_move_rows: file_system_tree_end_move_rows, begin_remove_rows: file_system_tree_begin_remove_rows, end_remove_rows: file_system_tree_end_remove_rows, }; let d_file_system_tree = FileSystemTree::new(file_system_tree_emit, model); let processes_emit = ProcessesEmitter { qobject: Arc::new(AtomicPtr::new(processes)), active_changed: processes_active_changed, new_data_ready: processes_new_data_ready, }; let model = ProcessesTree { qobject: processes, layout_about_to_be_changed: processes_layout_about_to_be_changed, layout_changed: processes_layout_changed, data_changed: processes_data_changed, begin_reset_model: processes_begin_reset_model, end_reset_model: processes_end_reset_model, begin_insert_rows: processes_begin_insert_rows, end_insert_rows: processes_end_insert_rows, begin_move_rows: processes_begin_move_rows, end_move_rows: processes_end_move_rows, begin_remove_rows: processes_begin_remove_rows, end_remove_rows: processes_end_remove_rows, }; let d_processes = Processes::new(processes_emit, model); let time_series_emit = TimeSeriesEmitter { qobject: Arc::new(AtomicPtr::new(time_series)), new_data_ready: time_series_new_data_ready, }; let model = TimeSeriesList { qobject: time_series, layout_about_to_be_changed: time_series_layout_about_to_be_changed, layout_changed: time_series_layout_changed, data_changed: time_series_data_changed, begin_reset_model: time_series_begin_reset_model, end_reset_model: time_series_end_reset_model, begin_insert_rows: time_series_begin_insert_rows, end_insert_rows: time_series_end_insert_rows, begin_move_rows: time_series_begin_move_rows, end_move_rows: time_series_end_move_rows, begin_remove_rows: time_series_begin_remove_rows, end_remove_rows: time_series_end_remove_rows, }; let d_time_series = TimeSeries::new(time_series_emit, model); let demo_emit = DemoEmitter { qobject: Arc::new(AtomicPtr::new(demo)), }; let d_demo = Demo::new(demo_emit, d_fibonacci, d_fibonacci_list, d_file_system_tree, d_processes, d_time_series); Box::into_raw(Box::new(d_demo)) } #[no_mangle] pub unsafe extern "C" fn demo_free(ptr: *mut Demo) { Box::from_raw(ptr).emit().clear(); } #[no_mangle] pub unsafe extern "C" fn demo_fibonacci_get(ptr: *mut Demo) -> *mut Fibonacci { (&mut *ptr).fibonacci_mut() } #[no_mangle] pub unsafe extern "C" fn demo_fibonacci_list_get(ptr: *mut Demo) -> *mut FibonacciList { (&mut *ptr).fibonacci_list_mut() } #[no_mangle] pub unsafe extern "C" fn demo_file_system_tree_get(ptr: *mut Demo) -> *mut FileSystemTree { (&mut *ptr).file_system_tree_mut() } #[no_mangle] pub unsafe extern "C" fn demo_processes_get(ptr: *mut Demo) -> *mut Processes { (&mut *ptr).processes_mut() } #[no_mangle] pub unsafe extern "C" fn demo_time_series_get(ptr: *mut Demo) -> *mut TimeSeries { (&mut *ptr).time_series_mut() } pub struct FibonacciQObject {} pub struct FibonacciEmitter { qobject: Arc>, input_changed: fn(*mut FibonacciQObject), result_changed: fn(*mut FibonacciQObject), } unsafe impl Send for FibonacciEmitter {} impl FibonacciEmitter { /// Clone the emitter /// /// The emitter can only be cloned when it is mutable. The emitter calls /// into C++ code which may call into Rust again. If emmitting is possible /// from immutable structures, that might lead to access to a mutable /// reference. That is undefined behaviour and forbidden. pub fn clone(&mut self) -> FibonacciEmitter { FibonacciEmitter { qobject: self.qobject.clone(), input_changed: self.input_changed, result_changed: self.result_changed, } } fn clear(&self) { let n: *const FibonacciQObject = null(); self.qobject.store(n as *mut FibonacciQObject, Ordering::SeqCst); } pub fn input_changed(&mut self) { let ptr = self.qobject.load(Ordering::SeqCst); if !ptr.is_null() { (self.input_changed)(ptr); } } pub fn result_changed(&mut self) { let ptr = self.qobject.load(Ordering::SeqCst); if !ptr.is_null() { (self.result_changed)(ptr); } } } pub trait FibonacciTrait { fn new(emit: FibonacciEmitter) -> Self; fn emit(&mut self) -> &mut FibonacciEmitter; fn input(&self) -> u32; fn set_input(&mut self, value: u32); fn result(&self) -> u64; } #[no_mangle] pub extern "C" fn fibonacci_new( fibonacci: *mut FibonacciQObject, fibonacci_input_changed: fn(*mut FibonacciQObject), fibonacci_result_changed: fn(*mut FibonacciQObject), ) -> *mut Fibonacci { let fibonacci_emit = FibonacciEmitter { qobject: Arc::new(AtomicPtr::new(fibonacci)), input_changed: fibonacci_input_changed, result_changed: fibonacci_result_changed, }; let d_fibonacci = Fibonacci::new(fibonacci_emit); Box::into_raw(Box::new(d_fibonacci)) } #[no_mangle] pub unsafe extern "C" fn fibonacci_free(ptr: *mut Fibonacci) { Box::from_raw(ptr).emit().clear(); } #[no_mangle] pub unsafe extern "C" fn fibonacci_input_get(ptr: *const Fibonacci) -> u32 { (&*ptr).input() } #[no_mangle] pub unsafe extern "C" fn fibonacci_input_set(ptr: *mut Fibonacci, v: u32) { (&mut *ptr).set_input(v); } #[no_mangle] pub unsafe extern "C" fn fibonacci_result_get(ptr: *const Fibonacci) -> u64 { (&*ptr).result() } pub struct FibonacciListQObject {} pub struct FibonacciListEmitter { qobject: Arc>, new_data_ready: fn(*mut FibonacciListQObject), } unsafe impl Send for FibonacciListEmitter {} impl FibonacciListEmitter { /// Clone the emitter /// /// The emitter can only be cloned when it is mutable. The emitter calls /// into C++ code which may call into Rust again. If emmitting is possible /// from immutable structures, that might lead to access to a mutable /// reference. That is undefined behaviour and forbidden. pub fn clone(&mut self) -> FibonacciListEmitter { FibonacciListEmitter { qobject: self.qobject.clone(), new_data_ready: self.new_data_ready, } } fn clear(&self) { let n: *const FibonacciListQObject = null(); self.qobject.store(n as *mut FibonacciListQObject, Ordering::SeqCst); } pub fn new_data_ready(&mut self) { let ptr = self.qobject.load(Ordering::SeqCst); if !ptr.is_null() { (self.new_data_ready)(ptr); } } } #[derive(Clone)] pub struct FibonacciListList { qobject: *mut FibonacciListQObject, layout_about_to_be_changed: fn(*mut FibonacciListQObject), layout_changed: fn(*mut FibonacciListQObject), data_changed: fn(*mut FibonacciListQObject, usize, usize), begin_reset_model: fn(*mut FibonacciListQObject), end_reset_model: fn(*mut FibonacciListQObject), begin_insert_rows: fn(*mut FibonacciListQObject, usize, usize), end_insert_rows: fn(*mut FibonacciListQObject), begin_move_rows: fn(*mut FibonacciListQObject, usize, usize, usize), end_move_rows: fn(*mut FibonacciListQObject), begin_remove_rows: fn(*mut FibonacciListQObject, usize, usize), end_remove_rows: fn(*mut FibonacciListQObject), } impl FibonacciListList { pub fn layout_about_to_be_changed(&mut self) { (self.layout_about_to_be_changed)(self.qobject); } pub fn layout_changed(&mut self) { (self.layout_changed)(self.qobject); } pub fn data_changed(&mut self, first: usize, last: usize) { (self.data_changed)(self.qobject, first, last); } pub fn begin_reset_model(&mut self) { (self.begin_reset_model)(self.qobject); } pub fn end_reset_model(&mut self) { (self.end_reset_model)(self.qobject); } pub fn begin_insert_rows(&mut self, first: usize, last: usize) { (self.begin_insert_rows)(self.qobject, first, last); } pub fn end_insert_rows(&mut self) { (self.end_insert_rows)(self.qobject); } pub fn begin_move_rows(&mut self, first: usize, last: usize, destination: usize) { (self.begin_move_rows)(self.qobject, first, last, destination); } pub fn end_move_rows(&mut self) { (self.end_move_rows)(self.qobject); } pub fn begin_remove_rows(&mut self, first: usize, last: usize) { (self.begin_remove_rows)(self.qobject, first, last); } pub fn end_remove_rows(&mut self) { (self.end_remove_rows)(self.qobject); } } pub trait FibonacciListTrait { fn new(emit: FibonacciListEmitter, model: FibonacciListList) -> Self; fn emit(&mut self) -> &mut FibonacciListEmitter; fn row_count(&self) -> usize; fn insert_rows(&mut self, _row: usize, _count: usize) -> bool { false } fn remove_rows(&mut self, _row: usize, _count: usize) -> bool { false } fn can_fetch_more(&self) -> bool { false } fn fetch_more(&mut self) {} fn sort(&mut self, _: u8, _: SortOrder) {} fn fibonacci_number(&self, index: usize) -> u64; fn row(&self, index: usize) -> u64; } #[no_mangle] pub extern "C" fn fibonacci_list_new( fibonacci_list: *mut FibonacciListQObject, fibonacci_list_new_data_ready: fn(*mut FibonacciListQObject), fibonacci_list_layout_about_to_be_changed: fn(*mut FibonacciListQObject), fibonacci_list_layout_changed: fn(*mut FibonacciListQObject), fibonacci_list_data_changed: fn(*mut FibonacciListQObject, usize, usize), fibonacci_list_begin_reset_model: fn(*mut FibonacciListQObject), fibonacci_list_end_reset_model: fn(*mut FibonacciListQObject), fibonacci_list_begin_insert_rows: fn(*mut FibonacciListQObject, usize, usize), fibonacci_list_end_insert_rows: fn(*mut FibonacciListQObject), fibonacci_list_begin_move_rows: fn(*mut FibonacciListQObject, usize, usize, usize), fibonacci_list_end_move_rows: fn(*mut FibonacciListQObject), fibonacci_list_begin_remove_rows: fn(*mut FibonacciListQObject, usize, usize), fibonacci_list_end_remove_rows: fn(*mut FibonacciListQObject), ) -> *mut FibonacciList { let fibonacci_list_emit = FibonacciListEmitter { qobject: Arc::new(AtomicPtr::new(fibonacci_list)), new_data_ready: fibonacci_list_new_data_ready, }; let model = FibonacciListList { qobject: fibonacci_list, layout_about_to_be_changed: fibonacci_list_layout_about_to_be_changed, layout_changed: fibonacci_list_layout_changed, data_changed: fibonacci_list_data_changed, begin_reset_model: fibonacci_list_begin_reset_model, end_reset_model: fibonacci_list_end_reset_model, begin_insert_rows: fibonacci_list_begin_insert_rows, end_insert_rows: fibonacci_list_end_insert_rows, begin_move_rows: fibonacci_list_begin_move_rows, end_move_rows: fibonacci_list_end_move_rows, begin_remove_rows: fibonacci_list_begin_remove_rows, end_remove_rows: fibonacci_list_end_remove_rows, }; let d_fibonacci_list = FibonacciList::new(fibonacci_list_emit, model); Box::into_raw(Box::new(d_fibonacci_list)) } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_free(ptr: *mut FibonacciList) { Box::from_raw(ptr).emit().clear(); } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_row_count(ptr: *const FibonacciList) -> c_int { to_c_int((&*ptr).row_count()) } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_insert_rows(ptr: *mut FibonacciList, row: c_int, count: c_int) -> bool { (&mut *ptr).insert_rows(to_usize(row), to_usize(count)) } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_remove_rows(ptr: *mut FibonacciList, row: c_int, count: c_int) -> bool { (&mut *ptr).remove_rows(to_usize(row), to_usize(count)) } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_can_fetch_more(ptr: *const FibonacciList) -> bool { (&*ptr).can_fetch_more() } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_fetch_more(ptr: *mut FibonacciList) { (&mut *ptr).fetch_more() } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_sort( ptr: *mut FibonacciList, column: u8, order: SortOrder, ) { (&mut *ptr).sort(column, order) } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_data_fibonacci_number(ptr: *const FibonacciList, row: c_int) -> u64 { let o = &*ptr; o.fibonacci_number(to_usize(row)).into() } #[no_mangle] pub unsafe extern "C" fn fibonacci_list_data_row(ptr: *const FibonacciList, row: c_int) -> u64 { let o = &*ptr; o.row(to_usize(row)).into() } pub struct FileSystemTreeQObject {} pub struct FileSystemTreeEmitter { qobject: Arc>, path_changed: fn(*mut FileSystemTreeQObject), new_data_ready: fn(*mut FileSystemTreeQObject, index: COption), } unsafe impl Send for FileSystemTreeEmitter {} impl FileSystemTreeEmitter { /// Clone the emitter /// /// The emitter can only be cloned when it is mutable. The emitter calls /// into C++ code which may call into Rust again. If emmitting is possible /// from immutable structures, that might lead to access to a mutable /// reference. That is undefined behaviour and forbidden. pub fn clone(&mut self) -> FileSystemTreeEmitter { FileSystemTreeEmitter { qobject: self.qobject.clone(), path_changed: self.path_changed, new_data_ready: self.new_data_ready, } } fn clear(&self) { let n: *const FileSystemTreeQObject = null(); self.qobject.store(n as *mut FileSystemTreeQObject, Ordering::SeqCst); } pub fn path_changed(&mut self) { let ptr = self.qobject.load(Ordering::SeqCst); if !ptr.is_null() { (self.path_changed)(ptr); } } pub fn new_data_ready(&mut self, item: Option) { let ptr = self.qobject.load(Ordering::SeqCst); if !ptr.is_null() { (self.new_data_ready)(ptr, item.into()); } } } #[derive(Clone)] pub struct FileSystemTreeTree { qobject: *mut FileSystemTreeQObject, layout_about_to_be_changed: fn(*mut FileSystemTreeQObject), layout_changed: fn(*mut FileSystemTreeQObject), data_changed: fn(*mut FileSystemTreeQObject, usize, usize), begin_reset_model: fn(*mut FileSystemTreeQObject), end_reset_model: fn(*mut FileSystemTreeQObject), begin_insert_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize), end_insert_rows: fn(*mut FileSystemTreeQObject), begin_move_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize, dest: COption, usize), end_move_rows: fn(*mut FileSystemTreeQObject), begin_remove_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize), end_remove_rows: fn(*mut FileSystemTreeQObject), } impl FileSystemTreeTree { pub fn layout_about_to_be_changed(&mut self) { (self.layout_about_to_be_changed)(self.qobject); } pub fn layout_changed(&mut self) { (self.layout_changed)(self.qobject); } pub fn data_changed(&mut self, first: usize, last: usize) { (self.data_changed)(self.qobject, first, last); } pub fn begin_reset_model(&mut self) { (self.begin_reset_model)(self.qobject); } pub fn end_reset_model(&mut self) { (self.end_reset_model)(self.qobject); } pub fn begin_insert_rows(&mut self, index: Option, first: usize, last: usize) { (self.begin_insert_rows)(self.qobject, index.into(), first, last); } pub fn end_insert_rows(&mut self) { (self.end_insert_rows)(self.qobject); } pub fn begin_move_rows(&mut self, index: Option, first: usize, last: usize, dest: Option, destination: usize) { (self.begin_move_rows)(self.qobject, index.into(), first, last, dest.into(), destination); } pub fn end_move_rows(&mut self) { (self.end_move_rows)(self.qobject); } pub fn begin_remove_rows(&mut self, index: Option, first: usize, last: usize) { (self.begin_remove_rows)(self.qobject, index.into(), first, last); } pub fn end_remove_rows(&mut self) { (self.end_remove_rows)(self.qobject); } } pub trait FileSystemTreeTrait { fn new(emit: FileSystemTreeEmitter, model: FileSystemTreeTree) -> Self; fn emit(&mut self) -> &mut FileSystemTreeEmitter; fn path(&self) -> Option<&str>; fn set_path(&mut self, value: Option); fn row_count(&self, _: Option) -> usize; fn can_fetch_more(&self, _: Option) -> bool { false } fn fetch_more(&mut self, _: Option) {} fn sort(&mut self, _: u8, _: SortOrder) {} fn check_row(&self, index: usize, row: usize) -> Option; fn index(&self, item: Option, row: usize) -> usize; fn parent(&self, index: usize) -> Option; fn row(&self, index: usize) -> usize; fn file_icon(&self, index: usize) -> &[u8]; fn file_name(&self, index: usize) -> String; fn file_path(&self, index: usize) -> Option; fn file_permissions(&self, index: usize) -> i32; fn file_size(&self, index: usize) -> Option; fn file_type(&self, index: usize) -> i32; } #[no_mangle] pub extern "C" fn file_system_tree_new( file_system_tree: *mut FileSystemTreeQObject, file_system_tree_path_changed: fn(*mut FileSystemTreeQObject), file_system_tree_new_data_ready: fn(*mut FileSystemTreeQObject, index: COption), file_system_tree_layout_about_to_be_changed: fn(*mut FileSystemTreeQObject), file_system_tree_layout_changed: fn(*mut FileSystemTreeQObject), file_system_tree_data_changed: fn(*mut FileSystemTreeQObject, usize, usize), file_system_tree_begin_reset_model: fn(*mut FileSystemTreeQObject), file_system_tree_end_reset_model: fn(*mut FileSystemTreeQObject), file_system_tree_begin_insert_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize), file_system_tree_end_insert_rows: fn(*mut FileSystemTreeQObject), file_system_tree_begin_move_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize, index: COption, usize), file_system_tree_end_move_rows: fn(*mut FileSystemTreeQObject), file_system_tree_begin_remove_rows: fn(*mut FileSystemTreeQObject, index: COption, usize, usize), file_system_tree_end_remove_rows: fn(*mut FileSystemTreeQObject), ) -> *mut FileSystemTree { let file_system_tree_emit = FileSystemTreeEmitter { qobject: Arc::new(AtomicPtr::new(file_system_tree)), path_changed: file_system_tree_path_changed, new_data_ready: file_system_tree_new_data_ready, }; let model = FileSystemTreeTree { qobject: file_system_tree, layout_about_to_be_changed: file_system_tree_layout_about_to_be_changed, layout_changed: file_system_tree_layout_changed, data_changed: file_system_tree_data_changed, begin_reset_model: file_system_tree_begin_reset_model, end_reset_model: file_system_tree_end_reset_model, begin_insert_rows: file_system_tree_begin_insert_rows, end_insert_rows: file_system_tree_end_insert_rows, begin_move_rows: file_system_tree_begin_move_rows, end_move_rows: file_system_tree_end_move_rows, begin_remove_rows: file_system_tree_begin_remove_rows, end_remove_rows: file_system_tree_end_remove_rows, }; let d_file_system_tree = FileSystemTree::new(file_system_tree_emit, model); Box::into_raw(Box::new(d_file_system_tree)) } #[no_mangle] pub unsafe extern "C" fn file_system_tree_free(ptr: *mut FileSystemTree) { Box::from_raw(ptr).emit().clear(); } #[no_mangle] pub unsafe extern "C" fn file_system_tree_path_get( ptr: *const FileSystemTree, p: *mut QString, set: fn(*mut QString, *const c_char, c_int), ) { let o = &*ptr; let v = o.path(); if let Some(v) = v { let s: *const c_char = v.as_ptr() as (*const c_char); set(p, s, to_c_int(v.len())); } } #[no_mangle] pub unsafe extern "C" fn file_system_tree_path_set(ptr: *mut FileSystemTree, v: *const c_ushort, len: c_int) { let o = &mut *ptr; let mut s = String::new(); set_string_from_utf16(&mut s, v, len); o.set_path(Some(s)); } #[no_mangle] pub unsafe extern "C" fn file_system_tree_path_set_none(ptr: *mut FileSystemTree) { let o = &mut *ptr; o.set_path(None); } #[no_mangle] pub unsafe extern "C" fn file_system_tree_row_count( ptr: *const FileSystemTree, index: COption, ) -> c_int { to_c_int((&*ptr).row_count(index.into())) } #[no_mangle] pub unsafe extern "C" fn file_system_tree_can_fetch_more( ptr: *const FileSystemTree, index: COption, ) -> bool { (&*ptr).can_fetch_more(index.into()) } #[no_mangle] pub unsafe extern "C" fn file_system_tree_fetch_more(ptr: *mut FileSystemTree, index: COption) { (&mut *ptr).fetch_more(index.into()) } #[no_mangle] pub unsafe extern "C" fn file_system_tree_sort( ptr: *mut FileSystemTree, column: u8, order: SortOrder ) { (&mut *ptr).sort(column, order) } #[no_mangle] pub unsafe extern "C" fn file_system_tree_check_row( ptr: *const FileSystemTree, index: usize, row: c_int, ) -> COption { (&*ptr).check_row(index.into(), to_usize(row)).into() } #[no_mangle] pub unsafe extern "C" fn file_system_tree_index( ptr: *const FileSystemTree, index: COption, row: c_int, ) -> usize { (&*ptr).index(index.into(), to_usize(row)) } #[no_mangle] pub unsafe extern "C" fn file_system_tree_parent(ptr: *const FileSystemTree, index: usize) -> QModelIndex { if let Some(parent) = (&*ptr).parent(index) { QModelIndex { row: to_c_int((&*ptr).row(parent)), internal_id: parent, } } else { QModelIndex { row: -1, internal_id: 0, } } } #[no_mangle] pub unsafe extern "C" fn file_system_tree_row(ptr: *const FileSystemTree, index: usize) -> c_int { to_c_int((&*ptr).row(index)) } #[no_mangle] pub unsafe extern "C" fn file_system_tree_data_file_icon( ptr: *const FileSystemTree, index: usize, d: *mut QByteArray, set: fn(*mut QByteArray, *const c_char, len: c_int), ) { let o = &*ptr; let data = o.file_icon(index); let s: *const c_char = data.as_ptr() as (*const c_char); set(d, s, to_c_int(data.len())); } #[no_mangle] pub unsafe extern "C" fn file_system_tree_data_file_name( ptr: *const FileSystemTree, index: usize, d: *mut QString, set: fn(*mut QString, *const c_char, len: c_int), ) { let o = &*ptr; let data = o.file_name(index); let s: *const c_char = data.as_ptr() as (*const c_char); set(d, s, to_c_int(data.len())); } #[no_mangle] pub unsafe extern "C" fn file_system_tree_data_file_path( ptr: *const FileSystemTree, index: usize, d: *mut QString, set: fn(*mut QString, *const c_char, len: c_int), ) { let o = &*ptr; let data = o.file_path(index); if let Some(data) = data { let s: *const c_char = data.as_ptr() as (*const c_char); set(d, s, to_c_int(data.len())); } } #[no_mangle] pub unsafe extern "C" fn file_system_tree_data_file_permissions(ptr: *const FileSystemTree, index: usize) -> i32 { let o = &*ptr; o.file_permissions(index).into() } #[no_mangle] pub unsafe extern "C" fn file_system_tree_data_file_size(ptr: *const FileSystemTree, index: usize) -> COption { let o = &*ptr; o.file_size(index).into() } #[no_mangle] pub unsafe extern "C" fn file_system_tree_data_file_type(ptr: *const FileSystemTree, index: usize) -> i32 { let o = &*ptr; o.file_type(index).into() } pub struct ProcessesQObject {} pub struct ProcessesEmitter { qobject: Arc>, active_changed: fn(*mut ProcessesQObject), new_data_ready: fn(*mut ProcessesQObject, index: COption), } unsafe impl Send for ProcessesEmitter {} impl ProcessesEmitter { /// Clone the emitter /// /// The emitter can only be cloned when it is mutable. The emitter calls /// into C++ code which may call into Rust again. If emmitting is possible /// from immutable structures, that might lead to access to a mutable /// reference. That is undefined behaviour and forbidden. pub fn clone(&mut self) -> ProcessesEmitter { ProcessesEmitter { qobject: self.qobject.clone(), active_changed: self.active_changed, new_data_ready: self.new_data_ready, } } fn clear(&self) { let n: *const ProcessesQObject = null(); self.qobject.store(n as *mut ProcessesQObject, Ordering::SeqCst); } pub fn active_changed(&mut self) { let ptr = self.qobject.load(Ordering::SeqCst); if !ptr.is_null() { (self.active_changed)(ptr); } } pub fn new_data_ready(&mut self, item: Option) { let ptr = self.qobject.load(Ordering::SeqCst); if !ptr.is_null() { (self.new_data_ready)(ptr, item.into()); } } } #[derive(Clone)] pub struct ProcessesTree { qobject: *mut ProcessesQObject, layout_about_to_be_changed: fn(*mut ProcessesQObject), layout_changed: fn(*mut ProcessesQObject), data_changed: fn(*mut ProcessesQObject, usize, usize), begin_reset_model: fn(*mut ProcessesQObject), end_reset_model: fn(*mut ProcessesQObject), begin_insert_rows: fn(*mut ProcessesQObject, index: COption, usize, usize), end_insert_rows: fn(*mut ProcessesQObject), begin_move_rows: fn(*mut ProcessesQObject, index: COption, usize, usize, dest: COption, usize), end_move_rows: fn(*mut ProcessesQObject), begin_remove_rows: fn(*mut ProcessesQObject, index: COption, usize, usize), end_remove_rows: fn(*mut ProcessesQObject), } impl ProcessesTree { pub fn layout_about_to_be_changed(&mut self) { (self.layout_about_to_be_changed)(self.qobject); } pub fn layout_changed(&mut self) { (self.layout_changed)(self.qobject); } pub fn data_changed(&mut self, first: usize, last: usize) { (self.data_changed)(self.qobject, first, last); } pub fn begin_reset_model(&mut self) { (self.begin_reset_model)(self.qobject); } pub fn end_reset_model(&mut self) { (self.end_reset_model)(self.qobject); } pub fn begin_insert_rows(&mut self, index: Option, first: usize, last: usize) { (self.begin_insert_rows)(self.qobject, index.into(), first, last); } pub fn end_insert_rows(&mut self) { (self.end_insert_rows)(self.qobject); } pub fn begin_move_rows(&mut self, index: Option, first: usize, last: usize, dest: Option, destination: usize) { (self.begin_move_rows)(self.qobject, index.into(), first, last, dest.into(), destination); } pub fn end_move_rows(&mut self) { (self.end_move_rows)(self.qobject); } pub fn begin_remove_rows(&mut self, index: Option, first: usize, last: usize) { (self.begin_remove_rows)(self.qobject, index.into(), first, last); } pub fn end_remove_rows(&mut self) { (self.end_remove_rows)(self.qobject); } } pub trait ProcessesTrait { fn new(emit: ProcessesEmitter, model: ProcessesTree) -> Self; fn emit(&mut self) -> &mut ProcessesEmitter; fn active(&self) -> bool; fn set_active(&mut self, value: bool); fn row_count(&self, _: Option) -> usize; fn can_fetch_more(&self, _: Option) -> bool { false } fn fetch_more(&mut self, _: Option) {} fn sort(&mut self, _: u8, _: SortOrder) {} fn check_row(&self, index: usize, row: usize) -> Option; fn index(&self, item: Option, row: usize) -> usize; fn parent(&self, index: usize) -> Option; fn row(&self, index: usize) -> usize; fn cmd(&self, index: usize) -> String; fn cpu_percentage(&self, index: usize) -> u8; fn cpu_usage(&self, index: usize) -> f32; fn memory(&self, index: usize) -> u64; fn name(&self, index: usize) -> &str; fn pid(&self, index: usize) -> u32; fn uid(&self, index: usize) -> u32; } #[no_mangle] pub extern "C" fn processes_new( processes: *mut ProcessesQObject, processes_active_changed: fn(*mut ProcessesQObject), processes_new_data_ready: fn(*mut ProcessesQObject, index: COption), processes_layout_about_to_be_changed: fn(*mut ProcessesQObject), processes_layout_changed: fn(*mut ProcessesQObject), processes_data_changed: fn(*mut ProcessesQObject, usize, usize), processes_begin_reset_model: fn(*mut ProcessesQObject), processes_end_reset_model: fn(*mut ProcessesQObject), processes_begin_insert_rows: fn(*mut ProcessesQObject, index: COption, usize, usize), processes_end_insert_rows: fn(*mut ProcessesQObject), processes_begin_move_rows: fn(*mut ProcessesQObject, index: COption, usize, usize, index: COption, usize), processes_end_move_rows: fn(*mut ProcessesQObject), processes_begin_remove_rows: fn(*mut ProcessesQObject, index: COption, usize, usize), processes_end_remove_rows: fn(*mut ProcessesQObject), ) -> *mut Processes { let processes_emit = ProcessesEmitter { qobject: Arc::new(AtomicPtr::new(processes)), active_changed: processes_active_changed, new_data_ready: processes_new_data_ready, }; let model = ProcessesTree { qobject: processes, layout_about_to_be_changed: processes_layout_about_to_be_changed, layout_changed: processes_layout_changed, data_changed: processes_data_changed, begin_reset_model: processes_begin_reset_model, end_reset_model: processes_end_reset_model, begin_insert_rows: processes_begin_insert_rows, end_insert_rows: processes_end_insert_rows, begin_move_rows: processes_begin_move_rows, end_move_rows: processes_end_move_rows, begin_remove_rows: processes_begin_remove_rows, end_remove_rows: processes_end_remove_rows, }; let d_processes = Processes::new(processes_emit, model); Box::into_raw(Box::new(d_processes)) } #[no_mangle] pub unsafe extern "C" fn processes_free(ptr: *mut Processes) { Box::from_raw(ptr).emit().clear(); } #[no_mangle] pub unsafe extern "C" fn processes_active_get(ptr: *const Processes) -> bool { (&*ptr).active() } #[no_mangle] pub unsafe extern "C" fn processes_active_set(ptr: *mut Processes, v: bool) { (&mut *ptr).set_active(v); } #[no_mangle] pub unsafe extern "C" fn processes_row_count( ptr: *const Processes, index: COption, ) -> c_int { to_c_int((&*ptr).row_count(index.into())) } #[no_mangle] pub unsafe extern "C" fn processes_can_fetch_more( ptr: *const Processes, index: COption, ) -> bool { (&*ptr).can_fetch_more(index.into()) } #[no_mangle] pub unsafe extern "C" fn processes_fetch_more(ptr: *mut Processes, index: COption) { (&mut *ptr).fetch_more(index.into()) } #[no_mangle] pub unsafe extern "C" fn processes_sort( ptr: *mut Processes, column: u8, order: SortOrder ) { (&mut *ptr).sort(column, order) } #[no_mangle] pub unsafe extern "C" fn processes_check_row( ptr: *const Processes, index: usize, row: c_int, ) -> COption { (&*ptr).check_row(index.into(), to_usize(row)).into() } #[no_mangle] pub unsafe extern "C" fn processes_index( ptr: *const Processes, index: COption, row: c_int, ) -> usize { (&*ptr).index(index.into(), to_usize(row)) } #[no_mangle] pub unsafe extern "C" fn processes_parent(ptr: *const Processes, index: usize) -> QModelIndex { if let Some(parent) = (&*ptr).parent(index) { QModelIndex { row: to_c_int((&*ptr).row(parent)), internal_id: parent, } } else { QModelIndex { row: -1, internal_id: 0, } } } #[no_mangle] pub unsafe extern "C" fn processes_row(ptr: *const Processes, index: usize) -> c_int { to_c_int((&*ptr).row(index)) } #[no_mangle] pub unsafe extern "C" fn processes_data_cmd( ptr: *const Processes, index: usize, d: *mut QString, set: fn(*mut QString, *const c_char, len: c_int), ) { let o = &*ptr; let data = o.cmd(index); let s: *const c_char = data.as_ptr() as (*const c_char); set(d, s, to_c_int(data.len())); } #[no_mangle] pub unsafe extern "C" fn processes_data_cpu_percentage(ptr: *const Processes, index: usize) -> u8 { let o = &*ptr; o.cpu_percentage(index).into() } #[no_mangle] pub unsafe extern "C" fn processes_data_cpu_usage(ptr: *const Processes, index: usize) -> f32 { let o = &*ptr; o.cpu_usage(index).into() } #[no_mangle] pub unsafe extern "C" fn processes_data_memory(ptr: *const Processes, index: usize) -> u64 { let o = &*ptr; o.memory(index).into() } #[no_mangle] pub unsafe extern "C" fn processes_data_name( ptr: *const Processes, index: usize, d: *mut QString, set: fn(*mut QString, *const c_char, len: c_int), ) { let o = &*ptr; let data = o.name(index); let s: *const c_char = data.as_ptr() as (*const c_char); set(d, s, to_c_int(data.len())); } #[no_mangle] pub unsafe extern "C" fn processes_data_pid(ptr: *const Processes, index: usize) -> u32 { let o = &*ptr; o.pid(index).into() } #[no_mangle] pub unsafe extern "C" fn processes_data_uid(ptr: *const Processes, index: usize) -> u32 { let o = &*ptr; o.uid(index).into() } pub struct TimeSeriesQObject {} pub struct TimeSeriesEmitter { qobject: Arc>, new_data_ready: fn(*mut TimeSeriesQObject), } unsafe impl Send for TimeSeriesEmitter {} impl TimeSeriesEmitter { /// Clone the emitter /// /// The emitter can only be cloned when it is mutable. The emitter calls /// into C++ code which may call into Rust again. If emmitting is possible /// from immutable structures, that might lead to access to a mutable /// reference. That is undefined behaviour and forbidden. pub fn clone(&mut self) -> TimeSeriesEmitter { TimeSeriesEmitter { qobject: self.qobject.clone(), new_data_ready: self.new_data_ready, } } fn clear(&self) { let n: *const TimeSeriesQObject = null(); self.qobject.store(n as *mut TimeSeriesQObject, Ordering::SeqCst); } pub fn new_data_ready(&mut self) { let ptr = self.qobject.load(Ordering::SeqCst); if !ptr.is_null() { (self.new_data_ready)(ptr); } } } #[derive(Clone)] pub struct TimeSeriesList { qobject: *mut TimeSeriesQObject, layout_about_to_be_changed: fn(*mut TimeSeriesQObject), layout_changed: fn(*mut TimeSeriesQObject), data_changed: fn(*mut TimeSeriesQObject, usize, usize), begin_reset_model: fn(*mut TimeSeriesQObject), end_reset_model: fn(*mut TimeSeriesQObject), begin_insert_rows: fn(*mut TimeSeriesQObject, usize, usize), end_insert_rows: fn(*mut TimeSeriesQObject), begin_move_rows: fn(*mut TimeSeriesQObject, usize, usize, usize), end_move_rows: fn(*mut TimeSeriesQObject), begin_remove_rows: fn(*mut TimeSeriesQObject, usize, usize), end_remove_rows: fn(*mut TimeSeriesQObject), } impl TimeSeriesList { pub fn layout_about_to_be_changed(&mut self) { (self.layout_about_to_be_changed)(self.qobject); } pub fn layout_changed(&mut self) { (self.layout_changed)(self.qobject); } pub fn data_changed(&mut self, first: usize, last: usize) { (self.data_changed)(self.qobject, first, last); } pub fn begin_reset_model(&mut self) { (self.begin_reset_model)(self.qobject); } pub fn end_reset_model(&mut self) { (self.end_reset_model)(self.qobject); } pub fn begin_insert_rows(&mut self, first: usize, last: usize) { (self.begin_insert_rows)(self.qobject, first, last); } pub fn end_insert_rows(&mut self) { (self.end_insert_rows)(self.qobject); } pub fn begin_move_rows(&mut self, first: usize, last: usize, destination: usize) { (self.begin_move_rows)(self.qobject, first, last, destination); } pub fn end_move_rows(&mut self) { (self.end_move_rows)(self.qobject); } pub fn begin_remove_rows(&mut self, first: usize, last: usize) { (self.begin_remove_rows)(self.qobject, first, last); } pub fn end_remove_rows(&mut self) { (self.end_remove_rows)(self.qobject); } } pub trait TimeSeriesTrait { fn new(emit: TimeSeriesEmitter, model: TimeSeriesList) -> Self; fn emit(&mut self) -> &mut TimeSeriesEmitter; fn row_count(&self) -> usize; fn insert_rows(&mut self, _row: usize, _count: usize) -> bool { false } fn remove_rows(&mut self, _row: usize, _count: usize) -> bool { false } fn can_fetch_more(&self) -> bool { false } fn fetch_more(&mut self) {} fn sort(&mut self, _: u8, _: SortOrder) {} fn cos(&self, index: usize) -> f32; fn set_cos(&mut self, index: usize, f32) -> bool; fn sin(&self, index: usize) -> f32; fn set_sin(&mut self, index: usize, f32) -> bool; fn time(&self, index: usize) -> f32; fn set_time(&mut self, index: usize, f32) -> bool; } #[no_mangle] pub extern "C" fn time_series_new( time_series: *mut TimeSeriesQObject, time_series_new_data_ready: fn(*mut TimeSeriesQObject), time_series_layout_about_to_be_changed: fn(*mut TimeSeriesQObject), time_series_layout_changed: fn(*mut TimeSeriesQObject), time_series_data_changed: fn(*mut TimeSeriesQObject, usize, usize), time_series_begin_reset_model: fn(*mut TimeSeriesQObject), time_series_end_reset_model: fn(*mut TimeSeriesQObject), time_series_begin_insert_rows: fn(*mut TimeSeriesQObject, usize, usize), time_series_end_insert_rows: fn(*mut TimeSeriesQObject), time_series_begin_move_rows: fn(*mut TimeSeriesQObject, usize, usize, usize), time_series_end_move_rows: fn(*mut TimeSeriesQObject), time_series_begin_remove_rows: fn(*mut TimeSeriesQObject, usize, usize), time_series_end_remove_rows: fn(*mut TimeSeriesQObject), ) -> *mut TimeSeries { let time_series_emit = TimeSeriesEmitter { qobject: Arc::new(AtomicPtr::new(time_series)), new_data_ready: time_series_new_data_ready, }; let model = TimeSeriesList { qobject: time_series, layout_about_to_be_changed: time_series_layout_about_to_be_changed, layout_changed: time_series_layout_changed, data_changed: time_series_data_changed, begin_reset_model: time_series_begin_reset_model, end_reset_model: time_series_end_reset_model, begin_insert_rows: time_series_begin_insert_rows, end_insert_rows: time_series_end_insert_rows, begin_move_rows: time_series_begin_move_rows, end_move_rows: time_series_end_move_rows, begin_remove_rows: time_series_begin_remove_rows, end_remove_rows: time_series_end_remove_rows, }; let d_time_series = TimeSeries::new(time_series_emit, model); Box::into_raw(Box::new(d_time_series)) } #[no_mangle] pub unsafe extern "C" fn time_series_free(ptr: *mut TimeSeries) { Box::from_raw(ptr).emit().clear(); } #[no_mangle] pub unsafe extern "C" fn time_series_row_count(ptr: *const TimeSeries) -> c_int { to_c_int((&*ptr).row_count()) } #[no_mangle] pub unsafe extern "C" fn time_series_insert_rows(ptr: *mut TimeSeries, row: c_int, count: c_int) -> bool { (&mut *ptr).insert_rows(to_usize(row), to_usize(count)) } #[no_mangle] pub unsafe extern "C" fn time_series_remove_rows(ptr: *mut TimeSeries, row: c_int, count: c_int) -> bool { (&mut *ptr).remove_rows(to_usize(row), to_usize(count)) } #[no_mangle] pub unsafe extern "C" fn time_series_can_fetch_more(ptr: *const TimeSeries) -> bool { (&*ptr).can_fetch_more() } #[no_mangle] pub unsafe extern "C" fn time_series_fetch_more(ptr: *mut TimeSeries) { (&mut *ptr).fetch_more() } #[no_mangle] pub unsafe extern "C" fn time_series_sort( ptr: *mut TimeSeries, column: u8, order: SortOrder, ) { (&mut *ptr).sort(column, order) } #[no_mangle] pub unsafe extern "C" fn time_series_data_cos(ptr: *const TimeSeries, row: c_int) -> f32 { let o = &*ptr; o.cos(to_usize(row)).into() } #[no_mangle] pub unsafe extern "C" fn time_series_set_data_cos( ptr: *mut TimeSeries, row: c_int, v: f32, ) -> bool { (&mut *ptr).set_cos(to_usize(row), v) } #[no_mangle] pub unsafe extern "C" fn time_series_data_sin(ptr: *const TimeSeries, row: c_int) -> f32 { let o = &*ptr; o.sin(to_usize(row)).into() } #[no_mangle] pub unsafe extern "C" fn time_series_set_data_sin( ptr: *mut TimeSeries, row: c_int, v: f32, ) -> bool { (&mut *ptr).set_sin(to_usize(row), v) } #[no_mangle] pub unsafe extern "C" fn time_series_data_time(ptr: *const TimeSeries, row: c_int) -> f32 { let o = &*ptr; o.time(to_usize(row)).into() } #[no_mangle] pub unsafe extern "C" fn time_series_set_data_time( ptr: *mut TimeSeries, row: c_int, v: f32, ) -> bool { (&mut *ptr).set_time(to_usize(row), v) }