Adapt code to changes in generator
parent
b603a2262b
commit
fa337c37b1
|
@ -62,7 +62,7 @@ impl FibonacciTrait for Fibonacci {
|
||||||
fn set_input(&mut self, value: u32) {
|
fn set_input(&mut self, value: u32) {
|
||||||
self.input = value;
|
self.input = value;
|
||||||
self.emit.input_changed();
|
self.emit.input_changed();
|
||||||
let emit = self.emit.clone();
|
let mut emit = self.emit.clone();
|
||||||
let result = self.result.clone();
|
let result = self.result.clone();
|
||||||
result.swap(0, Ordering::SeqCst);
|
result.swap(0, Ordering::SeqCst);
|
||||||
emit.result_changed();
|
emit.result_changed();
|
||||||
|
|
|
@ -23,9 +23,8 @@ use std::path::PathBuf;
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||||
use std::marker::Sync;
|
use std::marker::Sync;
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
pub struct DirEntry {
|
pub struct DirEntry {
|
||||||
name: OsString,
|
name: OsString,
|
||||||
|
@ -34,15 +33,13 @@ pub struct DirEntry {
|
||||||
icon: Vec<u8>,
|
icon: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Incoming<T> = Arc<Mutex<HashMap<usize, Vec<T>>>>;
|
|
||||||
|
|
||||||
impl Item for DirEntry {
|
impl Item for DirEntry {
|
||||||
fn new(name: &str) -> DirEntry {
|
fn new(name: &str) -> DirEntry {
|
||||||
DirEntry {
|
DirEntry {
|
||||||
name: OsString::from(name),
|
name: OsString::from(name),
|
||||||
metadata: metadata(name).ok(),
|
metadata: metadata(name).ok(),
|
||||||
path: None,
|
path: None,
|
||||||
icon: Vec::new()
|
icon: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn can_fetch_more(&self) -> bool {
|
fn can_fetch_more(&self) -> bool {
|
||||||
|
@ -66,10 +63,19 @@ impl Item for DirEntry {
|
||||||
fn icon(&self) -> &[u8] {
|
fn icon(&self) -> &[u8] {
|
||||||
&self.icon
|
&self.icon
|
||||||
}
|
}
|
||||||
fn retrieve(id: usize, parents: Vec<&DirEntry>, q: Incoming<Self>, emit: FileSystemTreeEmitter) {
|
fn retrieve(id: usize, parents: Vec<&Self>, outgoing: &Sender<(usize, PathBuf)>) {
|
||||||
let mut v = Vec::new();
|
|
||||||
let path: PathBuf = parents.into_iter().map(|e| &e.name).collect();
|
let path: PathBuf = parents.into_iter().map(|e| &e.name).collect();
|
||||||
thread::spawn(move || {
|
if let Err(e) = outgoing.send((id, path)) {
|
||||||
|
eprintln!("{}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn read_files(
|
||||||
|
incoming: Receiver<(usize, PathBuf)>,
|
||||||
|
outgoing: Sender<(usize, Vec<Self>)>,
|
||||||
|
mut emit: FileSystemTreeEmitter,
|
||||||
|
) {
|
||||||
|
thread::spawn(move || while let Ok((id, path)) = incoming.recv() {
|
||||||
|
let mut v = Vec::new();
|
||||||
if let Ok(it) = read_dir(&path) {
|
if let Ok(it) = read_dir(&path) {
|
||||||
for i in it.filter_map(|v| v.ok()) {
|
for i in it.filter_map(|v| v.ok()) {
|
||||||
let de = DirEntry {
|
let de = DirEntry {
|
||||||
|
@ -82,11 +88,11 @@ impl Item for DirEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v.sort_by(|a, b| a.name.cmp(&b.name));
|
v.sort_by(|a, b| a.name.cmp(&b.name));
|
||||||
let mut map = q.lock().unwrap();
|
if let Ok(()) = outgoing.send((id, v)) {
|
||||||
if !map.contains_key(&id) {
|
emit.new_data_ready(Some(id));
|
||||||
map.insert(id, v);
|
} else {
|
||||||
emit.new_data_ready(Some(id));
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +111,12 @@ impl Default for DirEntry {
|
||||||
pub trait Item: Default {
|
pub trait Item: Default {
|
||||||
fn new(name: &str) -> Self;
|
fn new(name: &str) -> Self;
|
||||||
fn can_fetch_more(&self) -> bool;
|
fn can_fetch_more(&self) -> bool;
|
||||||
fn retrieve(id: usize, parents: Vec<&Self>, q: Incoming<Self>, emit: FileSystemTreeEmitter);
|
fn retrieve(id: usize, parents: Vec<&Self>, outgoing: &Sender<(usize, PathBuf)>);
|
||||||
|
fn read_files(
|
||||||
|
incoming: Receiver<(usize, PathBuf)>,
|
||||||
|
outgoing: Sender<(usize, Vec<Self>)>,
|
||||||
|
emit: FileSystemTreeEmitter,
|
||||||
|
);
|
||||||
fn file_name(&self) -> String;
|
fn file_name(&self) -> String;
|
||||||
fn file_path(&self) -> Option<String>;
|
fn file_path(&self) -> Option<String>;
|
||||||
fn file_permissions(&self) -> i32;
|
fn file_permissions(&self) -> i32;
|
||||||
|
@ -128,7 +139,8 @@ pub struct RGeneralItemModel<T: Item> {
|
||||||
model: FileSystemTreeTree,
|
model: FileSystemTreeTree,
|
||||||
entries: Vec<Entry<T>>,
|
entries: Vec<Entry<T>>,
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
incoming: Incoming<T>,
|
outgoing: Sender<(usize, PathBuf)>,
|
||||||
|
incoming: Receiver<(usize, Vec<T>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Item> RGeneralItemModel<T>
|
impl<T: Item> RGeneralItemModel<T>
|
||||||
|
@ -152,43 +164,37 @@ where
|
||||||
fn get(&self, index: usize) -> &Entry<T> {
|
fn get(&self, index: usize) -> &Entry<T> {
|
||||||
&self.entries[index]
|
&self.entries[index]
|
||||||
}
|
}
|
||||||
fn retrieve(&mut self, index: usize) {
|
fn retrieve(&self, index: usize) {
|
||||||
let parents = self.get_parents(index);
|
let parents = self.get_parents(index);
|
||||||
let incoming = self.incoming.clone();
|
T::retrieve(index, parents, &self.outgoing);
|
||||||
T::retrieve(index, parents, incoming, self.emit.clone());
|
|
||||||
}
|
}
|
||||||
fn process_incoming(&mut self) {
|
fn process_incoming(&mut self) {
|
||||||
if let Ok(ref mut incoming) = self.incoming.try_lock() {
|
while let Ok((id, entries)) = self.incoming.try_recv() {
|
||||||
for (id, entries) in incoming.drain() {
|
if self.entries[id].children.is_some() {
|
||||||
if self.entries[id].children.is_some() {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
let mut new_entries = Vec::new();
|
||||||
let mut new_entries = Vec::new();
|
let mut children = Vec::new();
|
||||||
let mut children = Vec::new();
|
for (r, d) in entries.into_iter().enumerate() {
|
||||||
{
|
new_entries.push(Entry {
|
||||||
for (r, d) in entries.into_iter().enumerate() {
|
parent: Some(id),
|
||||||
let e = Entry {
|
row: r,
|
||||||
parent: Some(id),
|
children: None,
|
||||||
row: r,
|
data: d,
|
||||||
children: None,
|
});
|
||||||
data: d,
|
children.push(self.entries.len() + r);
|
||||||
};
|
}
|
||||||
children.push(self.entries.len() + r);
|
if new_entries.is_empty() {
|
||||||
new_entries.push(e);
|
|
||||||
}
|
|
||||||
if !new_entries.is_empty() {
|
|
||||||
self.model.begin_insert_rows(
|
|
||||||
Some(id),
|
|
||||||
0,
|
|
||||||
new_entries.len() - 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.entries[id].children = Some(children);
|
self.entries[id].children = Some(children);
|
||||||
if !new_entries.is_empty() {
|
} else {
|
||||||
self.entries.append(&mut new_entries);
|
self.model.begin_insert_rows(
|
||||||
self.model.end_insert_rows();
|
Some(id),
|
||||||
}
|
0,
|
||||||
|
new_entries.len() - 1,
|
||||||
|
);
|
||||||
|
self.entries[id].children = Some(children);
|
||||||
|
self.entries.append(&mut new_entries);
|
||||||
|
self.model.end_insert_rows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,13 +213,17 @@ impl<T: Item> FileSystemTreeTrait for RGeneralItemModel<T>
|
||||||
where
|
where
|
||||||
T: Sync + Send,
|
T: Sync + Send,
|
||||||
{
|
{
|
||||||
fn new(emit: FileSystemTreeEmitter, model: FileSystemTreeTree) -> Self {
|
fn new(mut emit: FileSystemTreeEmitter, model: FileSystemTreeTree) -> Self {
|
||||||
let mut tree = RGeneralItemModel {
|
let (outgoing, thread_incoming) = channel();
|
||||||
|
let (thread_outgoing, incoming) = channel::<(usize, Vec<T>)>();
|
||||||
|
T::read_files(thread_incoming, thread_outgoing, emit.clone());
|
||||||
|
let mut tree: RGeneralItemModel<T> = RGeneralItemModel {
|
||||||
emit,
|
emit,
|
||||||
model,
|
model,
|
||||||
entries: Vec::new(),
|
entries: Vec::new(),
|
||||||
path: None,
|
path: None,
|
||||||
incoming: Arc::new(Mutex::new(HashMap::new())),
|
outgoing,
|
||||||
|
incoming,
|
||||||
};
|
};
|
||||||
tree.reset();
|
tree.reset();
|
||||||
tree
|
tree
|
||||||
|
@ -222,7 +232,7 @@ where
|
||||||
&self.emit
|
&self.emit
|
||||||
}
|
}
|
||||||
fn path(&self) -> Option<&str> {
|
fn path(&self) -> Option<&str> {
|
||||||
self.path.as_ref().map(|s|&s[..])
|
self.path.as_ref().map(|s| &s[..])
|
||||||
}
|
}
|
||||||
fn set_path(&mut self, value: Option<String>) {
|
fn set_path(&mut self, value: Option<String>) {
|
||||||
if self.path != value {
|
if self.path != value {
|
||||||
|
@ -232,21 +242,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn can_fetch_more(&self, index: Option<usize>) -> bool {
|
fn can_fetch_more(&self, index: Option<usize>) -> bool {
|
||||||
if let Some(index) = index {
|
let entry = self.get(index.unwrap_or(0));
|
||||||
let entry = self.get(index);
|
entry.children.is_none() && entry.data.can_fetch_more()
|
||||||
entry.children.is_none() && entry.data.can_fetch_more()
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn fetch_more(&mut self, index: Option<usize>) {
|
fn fetch_more(&mut self, index: Option<usize>) {
|
||||||
self.process_incoming();
|
self.process_incoming();
|
||||||
if !self.can_fetch_more(index) {
|
if !self.can_fetch_more(index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Some(index) = index {
|
self.retrieve(index.unwrap_or(0));
|
||||||
self.retrieve(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn row_count(&self, index: Option<usize>) -> usize {
|
fn row_count(&self, index: Option<usize>) -> usize {
|
||||||
if self.entries.is_empty() {
|
if self.entries.is_empty() {
|
||||||
|
@ -257,10 +261,7 @@ where
|
||||||
if let Some(ref children) = entry.children {
|
if let Some(ref children) = entry.children {
|
||||||
children.len()
|
children.len()
|
||||||
} else {
|
} else {
|
||||||
// model does lazy loading, signal that data may be available
|
self.retrieve(i);
|
||||||
if self.can_fetch_more(index) {
|
|
||||||
self.emit.new_data_ready(index);
|
|
||||||
}
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -127,7 +127,7 @@ fn update() -> ProcessTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_thread(
|
fn update_thread(
|
||||||
emit: ProcessesEmitter,
|
mut emit: ProcessesEmitter,
|
||||||
incoming: Arc<Mutex<Option<ProcessTree>>>,
|
incoming: Arc<Mutex<Option<ProcessTree>>>,
|
||||||
mut active: bool,
|
mut active: bool,
|
||||||
status_channel: Receiver<ChangeState>,
|
status_channel: Receiver<ChangeState>,
|
||||||
|
@ -178,7 +178,7 @@ fn move_process(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_row(
|
fn remove_row(
|
||||||
model: &ProcessesTree,
|
model: &mut ProcessesTree,
|
||||||
parent: pid_t,
|
parent: pid_t,
|
||||||
row: usize,
|
row: usize,
|
||||||
map: &mut HashMap<pid_t, ProcessItem>,
|
map: &mut HashMap<pid_t, ProcessItem>,
|
||||||
|
@ -205,7 +205,7 @@ fn remove_row(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_row(
|
fn insert_row(
|
||||||
model: &ProcessesTree,
|
model: &mut ProcessesTree,
|
||||||
parent: pid_t,
|
parent: pid_t,
|
||||||
row: usize,
|
row: usize,
|
||||||
map: &mut HashMap<pid_t, ProcessItem>,
|
map: &mut HashMap<pid_t, ProcessItem>,
|
||||||
|
@ -236,7 +236,7 @@ fn cmp_f32(a: f32, b: f32) -> bool {
|
||||||
((a - b) / a).abs() < 0.01
|
((a - b) / a).abs() < 0.01
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync_row(model: &ProcessesTree, pid: pid_t, a: &mut Process, b: &Process) -> f32 {
|
fn sync_row(model: &mut ProcessesTree, pid: pid_t, a: &mut Process, b: &Process) -> f32 {
|
||||||
let mut changed = a.name != b.name;
|
let mut changed = a.name != b.name;
|
||||||
if changed {
|
if changed {
|
||||||
a.name.clone_from(&b.name);
|
a.name.clone_from(&b.name);
|
||||||
|
@ -264,7 +264,7 @@ fn sync_row(model: &ProcessesTree, pid: pid_t, a: &mut Process, b: &Process) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync_tree(
|
fn sync_tree(
|
||||||
model: &ProcessesTree,
|
model: &mut ProcessesTree,
|
||||||
parent: pid_t,
|
parent: pid_t,
|
||||||
amap: &mut HashMap<pid_t, ProcessItem>,
|
amap: &mut HashMap<pid_t, ProcessItem>,
|
||||||
bmap: &mut HashMap<pid_t, ProcessItem>,
|
bmap: &mut HashMap<pid_t, ProcessItem>,
|
||||||
|
@ -321,7 +321,7 @@ fn sync_tree(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProcessesTrait for Processes {
|
impl ProcessesTrait for Processes {
|
||||||
fn new(emit: ProcessesEmitter, model: ProcessesTree) -> Processes {
|
fn new(mut emit: ProcessesEmitter, model: ProcessesTree) -> Processes {
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
let p = Processes {
|
let p = Processes {
|
||||||
emit: emit.clone(),
|
emit: emit.clone(),
|
||||||
|
@ -382,7 +382,7 @@ impl ProcessesTrait for Processes {
|
||||||
} else {
|
} else {
|
||||||
let top = self.p.top.clone();
|
let top = self.p.top.clone();
|
||||||
for pid in top {
|
for pid in top {
|
||||||
sync_tree(&self.model, pid, &mut self.p.processes, &mut new.processes);
|
sync_tree(&mut self.model, pid, &mut self.p.processes, &mut new.processes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,6 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct DemoQObject {}
|
pub struct DemoQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct DemoEmitter {
|
pub struct DemoEmitter {
|
||||||
qobject: Arc<AtomicPtr<DemoQObject>>,
|
qobject: Arc<AtomicPtr<DemoQObject>>,
|
||||||
}
|
}
|
||||||
|
@ -102,6 +101,17 @@ pub struct DemoEmitter {
|
||||||
unsafe impl Send for DemoEmitter {}
|
unsafe impl Send for DemoEmitter {}
|
||||||
|
|
||||||
impl 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) {
|
fn clear(&self) {
|
||||||
let n: *const DemoQObject = null();
|
let n: *const DemoQObject = null();
|
||||||
self.qobject.store(n as *mut DemoQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut DemoQObject, Ordering::SeqCst);
|
||||||
|
@ -132,62 +142,62 @@ pub trait DemoTrait {
|
||||||
pub extern "C" fn demo_new(
|
pub extern "C" fn demo_new(
|
||||||
demo: *mut DemoQObject,
|
demo: *mut DemoQObject,
|
||||||
fibonacci: *mut FibonacciQObject,
|
fibonacci: *mut FibonacciQObject,
|
||||||
fibonacci_input_changed: fn(*const FibonacciQObject),
|
fibonacci_input_changed: fn(*mut FibonacciQObject),
|
||||||
fibonacci_result_changed: fn(*const FibonacciQObject),
|
fibonacci_result_changed: fn(*mut FibonacciQObject),
|
||||||
fibonacci_list: *mut FibonacciListQObject,
|
fibonacci_list: *mut FibonacciListQObject,
|
||||||
fibonacci_list_new_data_ready: fn(*const FibonacciListQObject),
|
fibonacci_list_new_data_ready: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_layout_about_to_be_changed: fn(*const FibonacciListQObject),
|
fibonacci_list_layout_about_to_be_changed: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_layout_changed: fn(*const FibonacciListQObject),
|
fibonacci_list_layout_changed: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_data_changed: fn(*const FibonacciListQObject, usize, usize),
|
fibonacci_list_data_changed: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
fibonacci_list_begin_reset_model: fn(*const FibonacciListQObject),
|
fibonacci_list_begin_reset_model: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_end_reset_model: fn(*const FibonacciListQObject),
|
fibonacci_list_end_reset_model: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_begin_insert_rows: fn(*const FibonacciListQObject, usize, usize),
|
fibonacci_list_begin_insert_rows: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
fibonacci_list_end_insert_rows: fn(*const FibonacciListQObject),
|
fibonacci_list_end_insert_rows: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_begin_move_rows: fn(*const FibonacciListQObject, usize, usize, usize),
|
fibonacci_list_begin_move_rows: fn(*mut FibonacciListQObject, usize, usize, usize),
|
||||||
fibonacci_list_end_move_rows: fn(*const FibonacciListQObject),
|
fibonacci_list_end_move_rows: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_begin_remove_rows: fn(*const FibonacciListQObject, usize, usize),
|
fibonacci_list_begin_remove_rows: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
fibonacci_list_end_remove_rows: fn(*const FibonacciListQObject),
|
fibonacci_list_end_remove_rows: fn(*mut FibonacciListQObject),
|
||||||
file_system_tree: *mut FileSystemTreeQObject,
|
file_system_tree: *mut FileSystemTreeQObject,
|
||||||
file_system_tree_path_changed: fn(*const FileSystemTreeQObject),
|
file_system_tree_path_changed: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_new_data_ready: fn(*const FileSystemTreeQObject, index: COption<usize>),
|
file_system_tree_new_data_ready: fn(*mut FileSystemTreeQObject, index: COption<usize>),
|
||||||
file_system_tree_layout_about_to_be_changed: fn(*const FileSystemTreeQObject),
|
file_system_tree_layout_about_to_be_changed: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_layout_changed: fn(*const FileSystemTreeQObject),
|
file_system_tree_layout_changed: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_data_changed: fn(*const FileSystemTreeQObject, usize, usize),
|
file_system_tree_data_changed: fn(*mut FileSystemTreeQObject, usize, usize),
|
||||||
file_system_tree_begin_reset_model: fn(*const FileSystemTreeQObject),
|
file_system_tree_begin_reset_model: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_end_reset_model: fn(*const FileSystemTreeQObject),
|
file_system_tree_end_reset_model: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_begin_insert_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
file_system_tree_begin_insert_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
||||||
file_system_tree_end_insert_rows: fn(*const FileSystemTreeQObject),
|
file_system_tree_end_insert_rows: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_begin_move_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
file_system_tree_begin_move_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
||||||
file_system_tree_end_move_rows: fn(*const FileSystemTreeQObject),
|
file_system_tree_end_move_rows: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_begin_remove_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
file_system_tree_begin_remove_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
||||||
file_system_tree_end_remove_rows: fn(*const FileSystemTreeQObject),
|
file_system_tree_end_remove_rows: fn(*mut FileSystemTreeQObject),
|
||||||
processes: *mut ProcessesQObject,
|
processes: *mut ProcessesQObject,
|
||||||
processes_active_changed: fn(*const ProcessesQObject),
|
processes_active_changed: fn(*mut ProcessesQObject),
|
||||||
processes_new_data_ready: fn(*const ProcessesQObject, index: COption<usize>),
|
processes_new_data_ready: fn(*mut ProcessesQObject, index: COption<usize>),
|
||||||
processes_layout_about_to_be_changed: fn(*const ProcessesQObject),
|
processes_layout_about_to_be_changed: fn(*mut ProcessesQObject),
|
||||||
processes_layout_changed: fn(*const ProcessesQObject),
|
processes_layout_changed: fn(*mut ProcessesQObject),
|
||||||
processes_data_changed: fn(*const ProcessesQObject, usize, usize),
|
processes_data_changed: fn(*mut ProcessesQObject, usize, usize),
|
||||||
processes_begin_reset_model: fn(*const ProcessesQObject),
|
processes_begin_reset_model: fn(*mut ProcessesQObject),
|
||||||
processes_end_reset_model: fn(*const ProcessesQObject),
|
processes_end_reset_model: fn(*mut ProcessesQObject),
|
||||||
processes_begin_insert_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize),
|
processes_begin_insert_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize),
|
||||||
processes_end_insert_rows: fn(*const ProcessesQObject),
|
processes_end_insert_rows: fn(*mut ProcessesQObject),
|
||||||
processes_begin_move_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
processes_begin_move_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
||||||
processes_end_move_rows: fn(*const ProcessesQObject),
|
processes_end_move_rows: fn(*mut ProcessesQObject),
|
||||||
processes_begin_remove_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize),
|
processes_begin_remove_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize),
|
||||||
processes_end_remove_rows: fn(*const ProcessesQObject),
|
processes_end_remove_rows: fn(*mut ProcessesQObject),
|
||||||
time_series: *mut TimeSeriesQObject,
|
time_series: *mut TimeSeriesQObject,
|
||||||
time_series_new_data_ready: fn(*const TimeSeriesQObject),
|
time_series_new_data_ready: fn(*mut TimeSeriesQObject),
|
||||||
time_series_layout_about_to_be_changed: fn(*const TimeSeriesQObject),
|
time_series_layout_about_to_be_changed: fn(*mut TimeSeriesQObject),
|
||||||
time_series_layout_changed: fn(*const TimeSeriesQObject),
|
time_series_layout_changed: fn(*mut TimeSeriesQObject),
|
||||||
time_series_data_changed: fn(*const TimeSeriesQObject, usize, usize),
|
time_series_data_changed: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
time_series_begin_reset_model: fn(*const TimeSeriesQObject),
|
time_series_begin_reset_model: fn(*mut TimeSeriesQObject),
|
||||||
time_series_end_reset_model: fn(*const TimeSeriesQObject),
|
time_series_end_reset_model: fn(*mut TimeSeriesQObject),
|
||||||
time_series_begin_insert_rows: fn(*const TimeSeriesQObject, usize, usize),
|
time_series_begin_insert_rows: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
time_series_end_insert_rows: fn(*const TimeSeriesQObject),
|
time_series_end_insert_rows: fn(*mut TimeSeriesQObject),
|
||||||
time_series_begin_move_rows: fn(*const TimeSeriesQObject, usize, usize, usize),
|
time_series_begin_move_rows: fn(*mut TimeSeriesQObject, usize, usize, usize),
|
||||||
time_series_end_move_rows: fn(*const TimeSeriesQObject),
|
time_series_end_move_rows: fn(*mut TimeSeriesQObject),
|
||||||
time_series_begin_remove_rows: fn(*const TimeSeriesQObject, usize, usize),
|
time_series_begin_remove_rows: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
time_series_end_remove_rows: fn(*const TimeSeriesQObject),
|
time_series_end_remove_rows: fn(*mut TimeSeriesQObject),
|
||||||
) -> *mut Demo {
|
) -> *mut Demo {
|
||||||
let fibonacci_emit = FibonacciEmitter {
|
let fibonacci_emit = FibonacciEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(fibonacci)),
|
qobject: Arc::new(AtomicPtr::new(fibonacci)),
|
||||||
|
@ -317,27 +327,39 @@ pub unsafe extern "C" fn demo_time_series_get(ptr: *mut Demo) -> *mut TimeSeries
|
||||||
|
|
||||||
pub struct FibonacciQObject {}
|
pub struct FibonacciQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct FibonacciEmitter {
|
pub struct FibonacciEmitter {
|
||||||
qobject: Arc<AtomicPtr<FibonacciQObject>>,
|
qobject: Arc<AtomicPtr<FibonacciQObject>>,
|
||||||
input_changed: fn(*const FibonacciQObject),
|
input_changed: fn(*mut FibonacciQObject),
|
||||||
result_changed: fn(*const FibonacciQObject),
|
result_changed: fn(*mut FibonacciQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for FibonacciEmitter {}
|
unsafe impl Send for FibonacciEmitter {}
|
||||||
|
|
||||||
impl 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) {
|
fn clear(&self) {
|
||||||
let n: *const FibonacciQObject = null();
|
let n: *const FibonacciQObject = null();
|
||||||
self.qobject.store(n as *mut FibonacciQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut FibonacciQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn input_changed(&self) {
|
pub fn input_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.input_changed)(ptr);
|
(self.input_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn result_changed(&self) {
|
pub fn result_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.result_changed)(ptr);
|
(self.result_changed)(ptr);
|
||||||
|
@ -356,8 +378,8 @@ pub trait FibonacciTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn fibonacci_new(
|
pub extern "C" fn fibonacci_new(
|
||||||
fibonacci: *mut FibonacciQObject,
|
fibonacci: *mut FibonacciQObject,
|
||||||
fibonacci_input_changed: fn(*const FibonacciQObject),
|
fibonacci_input_changed: fn(*mut FibonacciQObject),
|
||||||
fibonacci_result_changed: fn(*const FibonacciQObject),
|
fibonacci_result_changed: fn(*mut FibonacciQObject),
|
||||||
) -> *mut Fibonacci {
|
) -> *mut Fibonacci {
|
||||||
let fibonacci_emit = FibonacciEmitter {
|
let fibonacci_emit = FibonacciEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(fibonacci)),
|
qobject: Arc::new(AtomicPtr::new(fibonacci)),
|
||||||
|
@ -390,20 +412,31 @@ pub unsafe extern "C" fn fibonacci_result_get(ptr: *const Fibonacci) -> u64 {
|
||||||
|
|
||||||
pub struct FibonacciListQObject {}
|
pub struct FibonacciListQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct FibonacciListEmitter {
|
pub struct FibonacciListEmitter {
|
||||||
qobject: Arc<AtomicPtr<FibonacciListQObject>>,
|
qobject: Arc<AtomicPtr<FibonacciListQObject>>,
|
||||||
new_data_ready: fn(*const FibonacciListQObject),
|
new_data_ready: fn(*mut FibonacciListQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for FibonacciListEmitter {}
|
unsafe impl Send for FibonacciListEmitter {}
|
||||||
|
|
||||||
impl 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) {
|
fn clear(&self) {
|
||||||
let n: *const FibonacciListQObject = null();
|
let n: *const FibonacciListQObject = null();
|
||||||
self.qobject.store(n as *mut FibonacciListQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut FibonacciListQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self) {
|
pub fn new_data_ready(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr);
|
(self.new_data_ready)(ptr);
|
||||||
|
@ -413,52 +446,52 @@ impl FibonacciListEmitter {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FibonacciListList {
|
pub struct FibonacciListList {
|
||||||
qobject: *const FibonacciListQObject,
|
qobject: *mut FibonacciListQObject,
|
||||||
layout_about_to_be_changed: fn(*const FibonacciListQObject),
|
layout_about_to_be_changed: fn(*mut FibonacciListQObject),
|
||||||
layout_changed: fn(*const FibonacciListQObject),
|
layout_changed: fn(*mut FibonacciListQObject),
|
||||||
data_changed: fn(*const FibonacciListQObject, usize, usize),
|
data_changed: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
begin_reset_model: fn(*const FibonacciListQObject),
|
begin_reset_model: fn(*mut FibonacciListQObject),
|
||||||
end_reset_model: fn(*const FibonacciListQObject),
|
end_reset_model: fn(*mut FibonacciListQObject),
|
||||||
begin_insert_rows: fn(*const FibonacciListQObject, usize, usize),
|
begin_insert_rows: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
end_insert_rows: fn(*const FibonacciListQObject),
|
end_insert_rows: fn(*mut FibonacciListQObject),
|
||||||
begin_move_rows: fn(*const FibonacciListQObject, usize, usize, usize),
|
begin_move_rows: fn(*mut FibonacciListQObject, usize, usize, usize),
|
||||||
end_move_rows: fn(*const FibonacciListQObject),
|
end_move_rows: fn(*mut FibonacciListQObject),
|
||||||
begin_remove_rows: fn(*const FibonacciListQObject, usize, usize),
|
begin_remove_rows: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
end_remove_rows: fn(*const FibonacciListQObject),
|
end_remove_rows: fn(*mut FibonacciListQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FibonacciListList {
|
impl FibonacciListList {
|
||||||
pub fn layout_about_to_be_changed(&self) {
|
pub fn layout_about_to_be_changed(&mut self) {
|
||||||
(self.layout_about_to_be_changed)(self.qobject);
|
(self.layout_about_to_be_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn layout_changed(&self) {
|
pub fn layout_changed(&mut self) {
|
||||||
(self.layout_changed)(self.qobject);
|
(self.layout_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
pub fn data_changed(&mut self, first: usize, last: usize) {
|
||||||
(self.data_changed)(self.qobject, first, last);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, first, last);
|
(self.begin_insert_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_move_rows(&self, first: usize, last: usize, destination: usize) {
|
pub fn begin_move_rows(&mut self, first: usize, last: usize, destination: usize) {
|
||||||
(self.begin_move_rows)(self.qobject, first, last, destination);
|
(self.begin_move_rows)(self.qobject, first, last, destination);
|
||||||
}
|
}
|
||||||
pub fn end_move_rows(&self) {
|
pub fn end_move_rows(&mut self) {
|
||||||
(self.end_move_rows)(self.qobject);
|
(self.end_move_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, first: usize, last: usize) {
|
pub fn begin_remove_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_remove_rows)(self.qobject, first, last);
|
(self.begin_remove_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,18 +514,18 @@ pub trait FibonacciListTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn fibonacci_list_new(
|
pub extern "C" fn fibonacci_list_new(
|
||||||
fibonacci_list: *mut FibonacciListQObject,
|
fibonacci_list: *mut FibonacciListQObject,
|
||||||
fibonacci_list_new_data_ready: fn(*const FibonacciListQObject),
|
fibonacci_list_new_data_ready: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_layout_about_to_be_changed: fn(*const FibonacciListQObject),
|
fibonacci_list_layout_about_to_be_changed: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_layout_changed: fn(*const FibonacciListQObject),
|
fibonacci_list_layout_changed: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_data_changed: fn(*const FibonacciListQObject, usize, usize),
|
fibonacci_list_data_changed: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
fibonacci_list_begin_reset_model: fn(*const FibonacciListQObject),
|
fibonacci_list_begin_reset_model: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_end_reset_model: fn(*const FibonacciListQObject),
|
fibonacci_list_end_reset_model: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_begin_insert_rows: fn(*const FibonacciListQObject, usize, usize),
|
fibonacci_list_begin_insert_rows: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
fibonacci_list_end_insert_rows: fn(*const FibonacciListQObject),
|
fibonacci_list_end_insert_rows: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_begin_move_rows: fn(*const FibonacciListQObject, usize, usize, usize),
|
fibonacci_list_begin_move_rows: fn(*mut FibonacciListQObject, usize, usize, usize),
|
||||||
fibonacci_list_end_move_rows: fn(*const FibonacciListQObject),
|
fibonacci_list_end_move_rows: fn(*mut FibonacciListQObject),
|
||||||
fibonacci_list_begin_remove_rows: fn(*const FibonacciListQObject, usize, usize),
|
fibonacci_list_begin_remove_rows: fn(*mut FibonacciListQObject, usize, usize),
|
||||||
fibonacci_list_end_remove_rows: fn(*const FibonacciListQObject),
|
fibonacci_list_end_remove_rows: fn(*mut FibonacciListQObject),
|
||||||
) -> *mut FibonacciList {
|
) -> *mut FibonacciList {
|
||||||
let fibonacci_list_emit = FibonacciListEmitter {
|
let fibonacci_list_emit = FibonacciListEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(fibonacci_list)),
|
qobject: Arc::new(AtomicPtr::new(fibonacci_list)),
|
||||||
|
@ -564,27 +597,39 @@ pub unsafe extern "C" fn fibonacci_list_data_row(ptr: *const FibonacciList, row:
|
||||||
|
|
||||||
pub struct FileSystemTreeQObject {}
|
pub struct FileSystemTreeQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct FileSystemTreeEmitter {
|
pub struct FileSystemTreeEmitter {
|
||||||
qobject: Arc<AtomicPtr<FileSystemTreeQObject>>,
|
qobject: Arc<AtomicPtr<FileSystemTreeQObject>>,
|
||||||
path_changed: fn(*const FileSystemTreeQObject),
|
path_changed: fn(*mut FileSystemTreeQObject),
|
||||||
new_data_ready: fn(*const FileSystemTreeQObject, index: COption<usize>),
|
new_data_ready: fn(*mut FileSystemTreeQObject, index: COption<usize>),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for FileSystemTreeEmitter {}
|
unsafe impl Send for FileSystemTreeEmitter {}
|
||||||
|
|
||||||
impl 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) {
|
fn clear(&self) {
|
||||||
let n: *const FileSystemTreeQObject = null();
|
let n: *const FileSystemTreeQObject = null();
|
||||||
self.qobject.store(n as *mut FileSystemTreeQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut FileSystemTreeQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn path_changed(&self) {
|
pub fn path_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.path_changed)(ptr);
|
(self.path_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self, item: Option<usize>) {
|
pub fn new_data_ready(&mut self, item: Option<usize>) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr, item.into());
|
(self.new_data_ready)(ptr, item.into());
|
||||||
|
@ -594,52 +639,52 @@ impl FileSystemTreeEmitter {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FileSystemTreeTree {
|
pub struct FileSystemTreeTree {
|
||||||
qobject: *const FileSystemTreeQObject,
|
qobject: *mut FileSystemTreeQObject,
|
||||||
layout_about_to_be_changed: fn(*const FileSystemTreeQObject),
|
layout_about_to_be_changed: fn(*mut FileSystemTreeQObject),
|
||||||
layout_changed: fn(*const FileSystemTreeQObject),
|
layout_changed: fn(*mut FileSystemTreeQObject),
|
||||||
data_changed: fn(*const FileSystemTreeQObject, usize, usize),
|
data_changed: fn(*mut FileSystemTreeQObject, usize, usize),
|
||||||
begin_reset_model: fn(*const FileSystemTreeQObject),
|
begin_reset_model: fn(*mut FileSystemTreeQObject),
|
||||||
end_reset_model: fn(*const FileSystemTreeQObject),
|
end_reset_model: fn(*mut FileSystemTreeQObject),
|
||||||
begin_insert_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
begin_insert_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
||||||
end_insert_rows: fn(*const FileSystemTreeQObject),
|
end_insert_rows: fn(*mut FileSystemTreeQObject),
|
||||||
begin_move_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize, dest: COption<usize>, usize),
|
begin_move_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize, dest: COption<usize>, usize),
|
||||||
end_move_rows: fn(*const FileSystemTreeQObject),
|
end_move_rows: fn(*mut FileSystemTreeQObject),
|
||||||
begin_remove_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
begin_remove_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
||||||
end_remove_rows: fn(*const FileSystemTreeQObject),
|
end_remove_rows: fn(*mut FileSystemTreeQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileSystemTreeTree {
|
impl FileSystemTreeTree {
|
||||||
pub fn layout_about_to_be_changed(&self) {
|
pub fn layout_about_to_be_changed(&mut self) {
|
||||||
(self.layout_about_to_be_changed)(self.qobject);
|
(self.layout_about_to_be_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn layout_changed(&self) {
|
pub fn layout_changed(&mut self) {
|
||||||
(self.layout_changed)(self.qobject);
|
(self.layout_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
pub fn data_changed(&mut self, first: usize, last: usize) {
|
||||||
(self.data_changed)(self.qobject, first, last);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, index: Option<usize>, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, index: Option<usize>, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, index.into(), first, last);
|
(self.begin_insert_rows)(self.qobject, index.into(), first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_move_rows(&self, index: Option<usize>, first: usize, last: usize, dest: Option<usize>, destination: usize) {
|
pub fn begin_move_rows(&mut self, index: Option<usize>, first: usize, last: usize, dest: Option<usize>, destination: usize) {
|
||||||
(self.begin_move_rows)(self.qobject, index.into(), first, last, dest.into(), destination);
|
(self.begin_move_rows)(self.qobject, index.into(), first, last, dest.into(), destination);
|
||||||
}
|
}
|
||||||
pub fn end_move_rows(&self) {
|
pub fn end_move_rows(&mut self) {
|
||||||
(self.end_move_rows)(self.qobject);
|
(self.end_move_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, index: Option<usize>, first: usize, last: usize) {
|
pub fn begin_remove_rows(&mut self, index: Option<usize>, first: usize, last: usize) {
|
||||||
(self.begin_remove_rows)(self.qobject, index.into(), first, last);
|
(self.begin_remove_rows)(self.qobject, index.into(), first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -670,19 +715,19 @@ pub trait FileSystemTreeTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn file_system_tree_new(
|
pub extern "C" fn file_system_tree_new(
|
||||||
file_system_tree: *mut FileSystemTreeQObject,
|
file_system_tree: *mut FileSystemTreeQObject,
|
||||||
file_system_tree_path_changed: fn(*const FileSystemTreeQObject),
|
file_system_tree_path_changed: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_new_data_ready: fn(*const FileSystemTreeQObject, index: COption<usize>),
|
file_system_tree_new_data_ready: fn(*mut FileSystemTreeQObject, index: COption<usize>),
|
||||||
file_system_tree_layout_about_to_be_changed: fn(*const FileSystemTreeQObject),
|
file_system_tree_layout_about_to_be_changed: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_layout_changed: fn(*const FileSystemTreeQObject),
|
file_system_tree_layout_changed: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_data_changed: fn(*const FileSystemTreeQObject, usize, usize),
|
file_system_tree_data_changed: fn(*mut FileSystemTreeQObject, usize, usize),
|
||||||
file_system_tree_begin_reset_model: fn(*const FileSystemTreeQObject),
|
file_system_tree_begin_reset_model: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_end_reset_model: fn(*const FileSystemTreeQObject),
|
file_system_tree_end_reset_model: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_begin_insert_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
file_system_tree_begin_insert_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
||||||
file_system_tree_end_insert_rows: fn(*const FileSystemTreeQObject),
|
file_system_tree_end_insert_rows: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_begin_move_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
file_system_tree_begin_move_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
||||||
file_system_tree_end_move_rows: fn(*const FileSystemTreeQObject),
|
file_system_tree_end_move_rows: fn(*mut FileSystemTreeQObject),
|
||||||
file_system_tree_begin_remove_rows: fn(*const FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
file_system_tree_begin_remove_rows: fn(*mut FileSystemTreeQObject, index: COption<usize>, usize, usize),
|
||||||
file_system_tree_end_remove_rows: fn(*const FileSystemTreeQObject),
|
file_system_tree_end_remove_rows: fn(*mut FileSystemTreeQObject),
|
||||||
) -> *mut FileSystemTree {
|
) -> *mut FileSystemTree {
|
||||||
let file_system_tree_emit = FileSystemTreeEmitter {
|
let file_system_tree_emit = FileSystemTreeEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(file_system_tree)),
|
qobject: Arc::new(AtomicPtr::new(file_system_tree)),
|
||||||
|
@ -859,27 +904,39 @@ pub unsafe extern "C" fn file_system_tree_data_file_type(ptr: *const FileSystemT
|
||||||
|
|
||||||
pub struct ProcessesQObject {}
|
pub struct ProcessesQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct ProcessesEmitter {
|
pub struct ProcessesEmitter {
|
||||||
qobject: Arc<AtomicPtr<ProcessesQObject>>,
|
qobject: Arc<AtomicPtr<ProcessesQObject>>,
|
||||||
active_changed: fn(*const ProcessesQObject),
|
active_changed: fn(*mut ProcessesQObject),
|
||||||
new_data_ready: fn(*const ProcessesQObject, index: COption<usize>),
|
new_data_ready: fn(*mut ProcessesQObject, index: COption<usize>),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for ProcessesEmitter {}
|
unsafe impl Send for ProcessesEmitter {}
|
||||||
|
|
||||||
impl 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) {
|
fn clear(&self) {
|
||||||
let n: *const ProcessesQObject = null();
|
let n: *const ProcessesQObject = null();
|
||||||
self.qobject.store(n as *mut ProcessesQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut ProcessesQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn active_changed(&self) {
|
pub fn active_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.active_changed)(ptr);
|
(self.active_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self, item: Option<usize>) {
|
pub fn new_data_ready(&mut self, item: Option<usize>) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr, item.into());
|
(self.new_data_ready)(ptr, item.into());
|
||||||
|
@ -889,52 +946,52 @@ impl ProcessesEmitter {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ProcessesTree {
|
pub struct ProcessesTree {
|
||||||
qobject: *const ProcessesQObject,
|
qobject: *mut ProcessesQObject,
|
||||||
layout_about_to_be_changed: fn(*const ProcessesQObject),
|
layout_about_to_be_changed: fn(*mut ProcessesQObject),
|
||||||
layout_changed: fn(*const ProcessesQObject),
|
layout_changed: fn(*mut ProcessesQObject),
|
||||||
data_changed: fn(*const ProcessesQObject, usize, usize),
|
data_changed: fn(*mut ProcessesQObject, usize, usize),
|
||||||
begin_reset_model: fn(*const ProcessesQObject),
|
begin_reset_model: fn(*mut ProcessesQObject),
|
||||||
end_reset_model: fn(*const ProcessesQObject),
|
end_reset_model: fn(*mut ProcessesQObject),
|
||||||
begin_insert_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize),
|
begin_insert_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize),
|
||||||
end_insert_rows: fn(*const ProcessesQObject),
|
end_insert_rows: fn(*mut ProcessesQObject),
|
||||||
begin_move_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize, dest: COption<usize>, usize),
|
begin_move_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize, dest: COption<usize>, usize),
|
||||||
end_move_rows: fn(*const ProcessesQObject),
|
end_move_rows: fn(*mut ProcessesQObject),
|
||||||
begin_remove_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize),
|
begin_remove_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize),
|
||||||
end_remove_rows: fn(*const ProcessesQObject),
|
end_remove_rows: fn(*mut ProcessesQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProcessesTree {
|
impl ProcessesTree {
|
||||||
pub fn layout_about_to_be_changed(&self) {
|
pub fn layout_about_to_be_changed(&mut self) {
|
||||||
(self.layout_about_to_be_changed)(self.qobject);
|
(self.layout_about_to_be_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn layout_changed(&self) {
|
pub fn layout_changed(&mut self) {
|
||||||
(self.layout_changed)(self.qobject);
|
(self.layout_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
pub fn data_changed(&mut self, first: usize, last: usize) {
|
||||||
(self.data_changed)(self.qobject, first, last);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, index: Option<usize>, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, index: Option<usize>, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, index.into(), first, last);
|
(self.begin_insert_rows)(self.qobject, index.into(), first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_move_rows(&self, index: Option<usize>, first: usize, last: usize, dest: Option<usize>, destination: usize) {
|
pub fn begin_move_rows(&mut self, index: Option<usize>, first: usize, last: usize, dest: Option<usize>, destination: usize) {
|
||||||
(self.begin_move_rows)(self.qobject, index.into(), first, last, dest.into(), destination);
|
(self.begin_move_rows)(self.qobject, index.into(), first, last, dest.into(), destination);
|
||||||
}
|
}
|
||||||
pub fn end_move_rows(&self) {
|
pub fn end_move_rows(&mut self) {
|
||||||
(self.end_move_rows)(self.qobject);
|
(self.end_move_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, index: Option<usize>, first: usize, last: usize) {
|
pub fn begin_remove_rows(&mut self, index: Option<usize>, first: usize, last: usize) {
|
||||||
(self.begin_remove_rows)(self.qobject, index.into(), first, last);
|
(self.begin_remove_rows)(self.qobject, index.into(), first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -966,19 +1023,19 @@ pub trait ProcessesTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn processes_new(
|
pub extern "C" fn processes_new(
|
||||||
processes: *mut ProcessesQObject,
|
processes: *mut ProcessesQObject,
|
||||||
processes_active_changed: fn(*const ProcessesQObject),
|
processes_active_changed: fn(*mut ProcessesQObject),
|
||||||
processes_new_data_ready: fn(*const ProcessesQObject, index: COption<usize>),
|
processes_new_data_ready: fn(*mut ProcessesQObject, index: COption<usize>),
|
||||||
processes_layout_about_to_be_changed: fn(*const ProcessesQObject),
|
processes_layout_about_to_be_changed: fn(*mut ProcessesQObject),
|
||||||
processes_layout_changed: fn(*const ProcessesQObject),
|
processes_layout_changed: fn(*mut ProcessesQObject),
|
||||||
processes_data_changed: fn(*const ProcessesQObject, usize, usize),
|
processes_data_changed: fn(*mut ProcessesQObject, usize, usize),
|
||||||
processes_begin_reset_model: fn(*const ProcessesQObject),
|
processes_begin_reset_model: fn(*mut ProcessesQObject),
|
||||||
processes_end_reset_model: fn(*const ProcessesQObject),
|
processes_end_reset_model: fn(*mut ProcessesQObject),
|
||||||
processes_begin_insert_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize),
|
processes_begin_insert_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize),
|
||||||
processes_end_insert_rows: fn(*const ProcessesQObject),
|
processes_end_insert_rows: fn(*mut ProcessesQObject),
|
||||||
processes_begin_move_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
processes_begin_move_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
||||||
processes_end_move_rows: fn(*const ProcessesQObject),
|
processes_end_move_rows: fn(*mut ProcessesQObject),
|
||||||
processes_begin_remove_rows: fn(*const ProcessesQObject, index: COption<usize>, usize, usize),
|
processes_begin_remove_rows: fn(*mut ProcessesQObject, index: COption<usize>, usize, usize),
|
||||||
processes_end_remove_rows: fn(*const ProcessesQObject),
|
processes_end_remove_rows: fn(*mut ProcessesQObject),
|
||||||
) -> *mut Processes {
|
) -> *mut Processes {
|
||||||
let processes_emit = ProcessesEmitter {
|
let processes_emit = ProcessesEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(processes)),
|
qobject: Arc::new(AtomicPtr::new(processes)),
|
||||||
|
@ -1135,20 +1192,31 @@ pub unsafe extern "C" fn processes_data_uid(ptr: *const Processes, index: usize)
|
||||||
|
|
||||||
pub struct TimeSeriesQObject {}
|
pub struct TimeSeriesQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct TimeSeriesEmitter {
|
pub struct TimeSeriesEmitter {
|
||||||
qobject: Arc<AtomicPtr<TimeSeriesQObject>>,
|
qobject: Arc<AtomicPtr<TimeSeriesQObject>>,
|
||||||
new_data_ready: fn(*const TimeSeriesQObject),
|
new_data_ready: fn(*mut TimeSeriesQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for TimeSeriesEmitter {}
|
unsafe impl Send for TimeSeriesEmitter {}
|
||||||
|
|
||||||
impl 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) {
|
fn clear(&self) {
|
||||||
let n: *const TimeSeriesQObject = null();
|
let n: *const TimeSeriesQObject = null();
|
||||||
self.qobject.store(n as *mut TimeSeriesQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut TimeSeriesQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self) {
|
pub fn new_data_ready(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr);
|
(self.new_data_ready)(ptr);
|
||||||
|
@ -1158,52 +1226,52 @@ impl TimeSeriesEmitter {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct TimeSeriesList {
|
pub struct TimeSeriesList {
|
||||||
qobject: *const TimeSeriesQObject,
|
qobject: *mut TimeSeriesQObject,
|
||||||
layout_about_to_be_changed: fn(*const TimeSeriesQObject),
|
layout_about_to_be_changed: fn(*mut TimeSeriesQObject),
|
||||||
layout_changed: fn(*const TimeSeriesQObject),
|
layout_changed: fn(*mut TimeSeriesQObject),
|
||||||
data_changed: fn(*const TimeSeriesQObject, usize, usize),
|
data_changed: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
begin_reset_model: fn(*const TimeSeriesQObject),
|
begin_reset_model: fn(*mut TimeSeriesQObject),
|
||||||
end_reset_model: fn(*const TimeSeriesQObject),
|
end_reset_model: fn(*mut TimeSeriesQObject),
|
||||||
begin_insert_rows: fn(*const TimeSeriesQObject, usize, usize),
|
begin_insert_rows: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
end_insert_rows: fn(*const TimeSeriesQObject),
|
end_insert_rows: fn(*mut TimeSeriesQObject),
|
||||||
begin_move_rows: fn(*const TimeSeriesQObject, usize, usize, usize),
|
begin_move_rows: fn(*mut TimeSeriesQObject, usize, usize, usize),
|
||||||
end_move_rows: fn(*const TimeSeriesQObject),
|
end_move_rows: fn(*mut TimeSeriesQObject),
|
||||||
begin_remove_rows: fn(*const TimeSeriesQObject, usize, usize),
|
begin_remove_rows: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
end_remove_rows: fn(*const TimeSeriesQObject),
|
end_remove_rows: fn(*mut TimeSeriesQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TimeSeriesList {
|
impl TimeSeriesList {
|
||||||
pub fn layout_about_to_be_changed(&self) {
|
pub fn layout_about_to_be_changed(&mut self) {
|
||||||
(self.layout_about_to_be_changed)(self.qobject);
|
(self.layout_about_to_be_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn layout_changed(&self) {
|
pub fn layout_changed(&mut self) {
|
||||||
(self.layout_changed)(self.qobject);
|
(self.layout_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
pub fn data_changed(&mut self, first: usize, last: usize) {
|
||||||
(self.data_changed)(self.qobject, first, last);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, first, last);
|
(self.begin_insert_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_move_rows(&self, first: usize, last: usize, destination: usize) {
|
pub fn begin_move_rows(&mut self, first: usize, last: usize, destination: usize) {
|
||||||
(self.begin_move_rows)(self.qobject, first, last, destination);
|
(self.begin_move_rows)(self.qobject, first, last, destination);
|
||||||
}
|
}
|
||||||
pub fn end_move_rows(&self) {
|
pub fn end_move_rows(&mut self) {
|
||||||
(self.end_move_rows)(self.qobject);
|
(self.end_move_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, first: usize, last: usize) {
|
pub fn begin_remove_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_remove_rows)(self.qobject, first, last);
|
(self.begin_remove_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1230,18 +1298,18 @@ pub trait TimeSeriesTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn time_series_new(
|
pub extern "C" fn time_series_new(
|
||||||
time_series: *mut TimeSeriesQObject,
|
time_series: *mut TimeSeriesQObject,
|
||||||
time_series_new_data_ready: fn(*const TimeSeriesQObject),
|
time_series_new_data_ready: fn(*mut TimeSeriesQObject),
|
||||||
time_series_layout_about_to_be_changed: fn(*const TimeSeriesQObject),
|
time_series_layout_about_to_be_changed: fn(*mut TimeSeriesQObject),
|
||||||
time_series_layout_changed: fn(*const TimeSeriesQObject),
|
time_series_layout_changed: fn(*mut TimeSeriesQObject),
|
||||||
time_series_data_changed: fn(*const TimeSeriesQObject, usize, usize),
|
time_series_data_changed: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
time_series_begin_reset_model: fn(*const TimeSeriesQObject),
|
time_series_begin_reset_model: fn(*mut TimeSeriesQObject),
|
||||||
time_series_end_reset_model: fn(*const TimeSeriesQObject),
|
time_series_end_reset_model: fn(*mut TimeSeriesQObject),
|
||||||
time_series_begin_insert_rows: fn(*const TimeSeriesQObject, usize, usize),
|
time_series_begin_insert_rows: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
time_series_end_insert_rows: fn(*const TimeSeriesQObject),
|
time_series_end_insert_rows: fn(*mut TimeSeriesQObject),
|
||||||
time_series_begin_move_rows: fn(*const TimeSeriesQObject, usize, usize, usize),
|
time_series_begin_move_rows: fn(*mut TimeSeriesQObject, usize, usize, usize),
|
||||||
time_series_end_move_rows: fn(*const TimeSeriesQObject),
|
time_series_end_move_rows: fn(*mut TimeSeriesQObject),
|
||||||
time_series_begin_remove_rows: fn(*const TimeSeriesQObject, usize, usize),
|
time_series_begin_remove_rows: fn(*mut TimeSeriesQObject, usize, usize),
|
||||||
time_series_end_remove_rows: fn(*const TimeSeriesQObject),
|
time_series_end_remove_rows: fn(*mut TimeSeriesQObject),
|
||||||
) -> *mut TimeSeries {
|
) -> *mut TimeSeries {
|
||||||
let time_series_emit = TimeSeriesEmitter {
|
let time_series_emit = TimeSeriesEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(time_series)),
|
qobject: Arc::new(AtomicPtr::new(time_series)),
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
/* generated by rust_qt_binding_generator */
|
/* generated by rust_qt_binding_generator */
|
||||||
#![allow(unknown_lints)]
|
|
||||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
|
||||||
use libc::{c_char, c_ushort, c_int};
|
use libc::{c_char, c_ushort, c_int};
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::char::decode_utf16;
|
use std::char::decode_utf16;
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||||
use std::ptr::null;
|
use std::ptr::null;
|
||||||
|
|
||||||
use implementation::*;
|
use implementation::*;
|
||||||
|
@ -17,6 +16,17 @@ pub struct COption<T> {
|
||||||
some: bool,
|
some: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> COption<T> {
|
||||||
|
#![allow(dead_code)]
|
||||||
|
fn into(self) -> Option<T> {
|
||||||
|
if self.some {
|
||||||
|
Some(self.data)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> From<Option<T>> for COption<T>
|
impl<T> From<Option<T>> for COption<T>
|
||||||
where
|
where
|
||||||
T: Default,
|
T: Default,
|
||||||
|
@ -42,7 +52,6 @@ pub enum QString {}
|
||||||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
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 utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||||
let characters = decode_utf16(utf16.iter().cloned())
|
let characters = decode_utf16(utf16.iter().cloned())
|
||||||
.into_iter()
|
|
||||||
.map(|r| r.unwrap());
|
.map(|r| r.unwrap());
|
||||||
s.clear();
|
s.clear();
|
||||||
s.extend(characters);
|
s.extend(characters);
|
||||||
|
@ -82,71 +91,102 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct TodosQObject {}
|
pub struct TodosQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct TodosEmitter {
|
pub struct TodosEmitter {
|
||||||
qobject: Arc<Mutex<*const TodosQObject>>,
|
qobject: Arc<AtomicPtr<TodosQObject>>,
|
||||||
active_count_changed: fn(*const TodosQObject),
|
active_count_changed: fn(*mut TodosQObject),
|
||||||
count_changed: fn(*const TodosQObject),
|
count_changed: fn(*mut TodosQObject),
|
||||||
new_data_ready: fn(*const TodosQObject),
|
new_data_ready: fn(*mut TodosQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for TodosEmitter {}
|
unsafe impl Send for TodosEmitter {}
|
||||||
|
|
||||||
impl TodosEmitter {
|
impl TodosEmitter {
|
||||||
fn clear(&self) {
|
/// Clone the emitter
|
||||||
*self.qobject.lock().unwrap() = null();
|
///
|
||||||
|
/// 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) -> TodosEmitter {
|
||||||
|
TodosEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
active_count_changed: self.active_count_changed,
|
||||||
|
count_changed: self.count_changed,
|
||||||
|
new_data_ready: self.new_data_ready,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn active_count_changed(&self) {
|
fn clear(&self) {
|
||||||
let ptr = *self.qobject.lock().unwrap();
|
let n: *const TodosQObject = null();
|
||||||
|
self.qobject.store(n as *mut TodosQObject, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
pub fn active_count_changed(&mut self) {
|
||||||
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.active_count_changed)(ptr);
|
(self.active_count_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn count_changed(&self) {
|
pub fn count_changed(&mut self) {
|
||||||
let ptr = *self.qobject.lock().unwrap();
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.count_changed)(ptr);
|
(self.count_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self) {
|
pub fn new_data_ready(&mut self) {
|
||||||
let ptr = *self.qobject.lock().unwrap();
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr);
|
(self.new_data_ready)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct TodosList {
|
pub struct TodosList {
|
||||||
qobject: *const TodosQObject,
|
qobject: *mut TodosQObject,
|
||||||
data_changed: fn(*const TodosQObject, usize, usize),
|
layout_about_to_be_changed: fn(*mut TodosQObject),
|
||||||
begin_reset_model: fn(*const TodosQObject),
|
layout_changed: fn(*mut TodosQObject),
|
||||||
end_reset_model: fn(*const TodosQObject),
|
data_changed: fn(*mut TodosQObject, usize, usize),
|
||||||
begin_insert_rows: fn(*const TodosQObject, usize, usize),
|
begin_reset_model: fn(*mut TodosQObject),
|
||||||
end_insert_rows: fn(*const TodosQObject),
|
end_reset_model: fn(*mut TodosQObject),
|
||||||
begin_remove_rows: fn(*const TodosQObject, usize, usize),
|
begin_insert_rows: fn(*mut TodosQObject, usize, usize),
|
||||||
end_remove_rows: fn(*const TodosQObject),
|
end_insert_rows: fn(*mut TodosQObject),
|
||||||
|
begin_move_rows: fn(*mut TodosQObject, usize, usize, usize),
|
||||||
|
end_move_rows: fn(*mut TodosQObject),
|
||||||
|
begin_remove_rows: fn(*mut TodosQObject, usize, usize),
|
||||||
|
end_remove_rows: fn(*mut TodosQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TodosList {
|
impl TodosList {
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
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);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, first, last);
|
(self.begin_insert_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, first: usize, last: usize) {
|
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);
|
(self.begin_remove_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,30 +217,38 @@ pub trait TodosTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn todos_new(
|
pub extern "C" fn todos_new(
|
||||||
todos: *mut TodosQObject,
|
todos: *mut TodosQObject,
|
||||||
todos_active_count_changed: fn(*const TodosQObject),
|
todos_active_count_changed: fn(*mut TodosQObject),
|
||||||
todos_count_changed: fn(*const TodosQObject),
|
todos_count_changed: fn(*mut TodosQObject),
|
||||||
todos_new_data_ready: fn(*const TodosQObject),
|
todos_new_data_ready: fn(*mut TodosQObject),
|
||||||
todos_data_changed: fn(*const TodosQObject, usize, usize),
|
todos_layout_about_to_be_changed: fn(*mut TodosQObject),
|
||||||
todos_begin_reset_model: fn(*const TodosQObject),
|
todos_layout_changed: fn(*mut TodosQObject),
|
||||||
todos_end_reset_model: fn(*const TodosQObject),
|
todos_data_changed: fn(*mut TodosQObject, usize, usize),
|
||||||
todos_begin_insert_rows: fn(*const TodosQObject, usize, usize),
|
todos_begin_reset_model: fn(*mut TodosQObject),
|
||||||
todos_end_insert_rows: fn(*const TodosQObject),
|
todos_end_reset_model: fn(*mut TodosQObject),
|
||||||
todos_begin_remove_rows: fn(*const TodosQObject, usize, usize),
|
todos_begin_insert_rows: fn(*mut TodosQObject, usize, usize),
|
||||||
todos_end_remove_rows: fn(*const TodosQObject),
|
todos_end_insert_rows: fn(*mut TodosQObject),
|
||||||
|
todos_begin_move_rows: fn(*mut TodosQObject, usize, usize, usize),
|
||||||
|
todos_end_move_rows: fn(*mut TodosQObject),
|
||||||
|
todos_begin_remove_rows: fn(*mut TodosQObject, usize, usize),
|
||||||
|
todos_end_remove_rows: fn(*mut TodosQObject),
|
||||||
) -> *mut Todos {
|
) -> *mut Todos {
|
||||||
let todos_emit = TodosEmitter {
|
let todos_emit = TodosEmitter {
|
||||||
qobject: Arc::new(Mutex::new(todos)),
|
qobject: Arc::new(AtomicPtr::new(todos)),
|
||||||
active_count_changed: todos_active_count_changed,
|
active_count_changed: todos_active_count_changed,
|
||||||
count_changed: todos_count_changed,
|
count_changed: todos_count_changed,
|
||||||
new_data_ready: todos_new_data_ready,
|
new_data_ready: todos_new_data_ready,
|
||||||
};
|
};
|
||||||
let model = TodosList {
|
let model = TodosList {
|
||||||
qobject: todos,
|
qobject: todos,
|
||||||
|
layout_about_to_be_changed: todos_layout_about_to_be_changed,
|
||||||
|
layout_changed: todos_layout_changed,
|
||||||
data_changed: todos_data_changed,
|
data_changed: todos_data_changed,
|
||||||
begin_reset_model: todos_begin_reset_model,
|
begin_reset_model: todos_begin_reset_model,
|
||||||
end_reset_model: todos_end_reset_model,
|
end_reset_model: todos_end_reset_model,
|
||||||
begin_insert_rows: todos_begin_insert_rows,
|
begin_insert_rows: todos_begin_insert_rows,
|
||||||
end_insert_rows: todos_end_insert_rows,
|
end_insert_rows: todos_end_insert_rows,
|
||||||
|
begin_move_rows: todos_begin_move_rows,
|
||||||
|
end_move_rows: todos_end_move_rows,
|
||||||
begin_remove_rows: todos_begin_remove_rows,
|
begin_remove_rows: todos_begin_remove_rows,
|
||||||
end_remove_rows: todos_end_remove_rows,
|
end_remove_rows: todos_end_remove_rows,
|
||||||
};
|
};
|
||||||
|
@ -224,31 +272,31 @@ pub unsafe extern "C" fn todos_count_get(ptr: *const Todos) -> u64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn todos_add(ptr: *mut Todos, description_str: *const c_ushort, description_len: c_int) -> () {
|
pub unsafe extern "C" fn todos_add(ptr: *mut Todos, description_str: *const c_ushort, description_len: c_int) -> () {
|
||||||
let mut description = String::new();
|
let mut description = String::new();
|
||||||
set_string_from_utf16(&mut description, description_str, description_len);
|
set_string_from_utf16(&mut description, description_str, description_len);
|
||||||
let o = unsafe { &mut *ptr };
|
let o = &mut *ptr;
|
||||||
let r = o.add(description);
|
let r = o.add(description);
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn todos_clear_completed(ptr: *mut Todos) -> () {
|
pub unsafe extern "C" fn todos_clear_completed(ptr: *mut Todos) -> () {
|
||||||
let o = unsafe { &mut *ptr };
|
let o = &mut *ptr;
|
||||||
let r = o.clear_completed();
|
let r = o.clear_completed();
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn todos_remove(ptr: *mut Todos, index: u64) -> bool {
|
pub unsafe extern "C" fn todos_remove(ptr: *mut Todos, index: u64) -> bool {
|
||||||
let o = unsafe { &mut *ptr };
|
let o = &mut *ptr;
|
||||||
let r = o.remove(index);
|
let r = o.remove(index);
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn todos_set_all(ptr: *mut Todos, completed: bool) -> () {
|
pub unsafe extern "C" fn todos_set_all(ptr: *mut Todos, completed: bool) -> () {
|
||||||
let o = unsafe { &mut *ptr };
|
let o = &mut *ptr;
|
||||||
let r = o.set_all(completed);
|
let r = o.set_all(completed);
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
@ -283,8 +331,8 @@ pub unsafe extern "C" fn todos_sort(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn todos_data_completed(ptr: *const Todos, row: c_int) -> bool {
|
pub unsafe extern "C" fn todos_data_completed(ptr: *const Todos, row: c_int) -> bool {
|
||||||
let o = unsafe { &*ptr };
|
let o = &*ptr;
|
||||||
o.completed(to_usize(row)).into()
|
o.completed(to_usize(row)).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,23 +345,23 @@ pub unsafe extern "C" fn todos_set_data_completed(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn todos_data_description(
|
pub unsafe extern "C" fn todos_data_description(
|
||||||
ptr: *const Todos, row: c_int,
|
ptr: *const Todos, row: c_int,
|
||||||
d: *mut QString,
|
d: *mut QString,
|
||||||
set: fn(*mut QString, *const c_char, len: c_int),
|
set: fn(*mut QString, *const c_char, len: c_int),
|
||||||
) {
|
) {
|
||||||
let o = unsafe { &*ptr };
|
let o = &*ptr;
|
||||||
let data = o.description(to_usize(row));
|
let data = o.description(to_usize(row));
|
||||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||||
set(d, s, to_c_int(data.len()));
|
set(d, s, to_c_int(data.len()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn todos_set_data_description(
|
pub unsafe extern "C" fn todos_set_data_description(
|
||||||
ptr: *mut Todos, row: c_int,
|
ptr: *mut Todos, row: c_int,
|
||||||
s: *const c_ushort, len: c_int,
|
s: *const c_ushort, len: c_int,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let o = unsafe { &mut *ptr };
|
let o = &mut *ptr;
|
||||||
let mut v = String::new();
|
let mut v = String::new();
|
||||||
set_string_from_utf16(&mut v, s, len);
|
set_string_from_utf16(&mut v, s, len);
|
||||||
o.set_description(to_usize(row), v)
|
o.set_description(to_usize(row), v)
|
||||||
|
|
|
@ -30,11 +30,11 @@ namespace {
|
||||||
}
|
}
|
||||||
inline void todosActiveCountChanged(Todos* o)
|
inline void todosActiveCountChanged(Todos* o)
|
||||||
{
|
{
|
||||||
emit o->activeCountChanged();
|
Q_EMIT o->activeCountChanged();
|
||||||
}
|
}
|
||||||
inline void todosCountChanged(Todos* o)
|
inline void todosCountChanged(Todos* o)
|
||||||
{
|
{
|
||||||
emit o->countChanged();
|
Q_EMIT o->countChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -99,6 +99,7 @@ void Todos::fetchMore(const QModelIndex &parent)
|
||||||
todos_fetch_more(m_d);
|
todos_fetch_more(m_d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void Todos::updatePersistentIndexes() {}
|
||||||
|
|
||||||
void Todos::sort(int column, Qt::SortOrder order)
|
void Todos::sort(int column, Qt::SortOrder order)
|
||||||
{
|
{
|
||||||
|
@ -124,7 +125,7 @@ bool Todos::setCompleted(int row, bool value)
|
||||||
set = todos_set_data_completed(m_d, row, value);
|
set = todos_set_data_completed(m_d, row, value);
|
||||||
if (set) {
|
if (set) {
|
||||||
QModelIndex index = createIndex(row, 0, row);
|
QModelIndex index = createIndex(row, 0, row);
|
||||||
emit dataChanged(index, index);
|
Q_EMIT dataChanged(index, index);
|
||||||
}
|
}
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +143,7 @@ bool Todos::setDescription(int row, const QString& value)
|
||||||
set = todos_set_data_description(m_d, row, value.utf16(), value.length());
|
set = todos_set_data_description(m_d, row, value.utf16(), value.length());
|
||||||
if (set) {
|
if (set) {
|
||||||
QModelIndex index = createIndex(row, 0, row);
|
QModelIndex index = createIndex(row, 0, row);
|
||||||
emit dataChanged(index, index);
|
Q_EMIT dataChanged(index, index);
|
||||||
}
|
}
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
@ -158,6 +159,7 @@ QVariant Todos::data(const QModelIndex &index, int role) const
|
||||||
case Qt::UserRole + 1:
|
case Qt::UserRole + 1:
|
||||||
return QVariant::fromValue(description(index.row()));
|
return QVariant::fromValue(description(index.row()));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -216,11 +218,15 @@ bool Todos::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
Todos::Private* todos_new(Todos*, void (*)(Todos*), void (*)(Todos*),
|
Todos::Private* todos_new(Todos*, void (*)(Todos*), void (*)(Todos*),
|
||||||
void (*)(const Todos*),
|
void (*)(const Todos*),
|
||||||
|
void (*)(Todos*),
|
||||||
|
void (*)(Todos*),
|
||||||
void (*)(Todos*, quintptr, quintptr),
|
void (*)(Todos*, quintptr, quintptr),
|
||||||
void (*)(Todos*),
|
void (*)(Todos*),
|
||||||
void (*)(Todos*),
|
void (*)(Todos*),
|
||||||
void (*)(Todos*, int, int),
|
void (*)(Todos*, int, int),
|
||||||
void (*)(Todos*),
|
void (*)(Todos*),
|
||||||
|
void (*)(Todos*, int, int, int),
|
||||||
|
void (*)(Todos*),
|
||||||
void (*)(Todos*, int, int),
|
void (*)(Todos*, int, int),
|
||||||
void (*)(Todos*));
|
void (*)(Todos*));
|
||||||
void todos_free(Todos::Private*);
|
void todos_free(Todos::Private*);
|
||||||
|
@ -234,7 +240,7 @@ extern "C" {
|
||||||
|
|
||||||
Todos::Todos(bool /*owned*/, QObject *parent):
|
Todos::Todos(bool /*owned*/, QObject *parent):
|
||||||
QAbstractItemModel(parent),
|
QAbstractItemModel(parent),
|
||||||
m_d(0),
|
m_d(nullptr),
|
||||||
m_ownsPrivate(false)
|
m_ownsPrivate(false)
|
||||||
{
|
{
|
||||||
initHeaderData();
|
initHeaderData();
|
||||||
|
@ -246,7 +252,14 @@ Todos::Todos(QObject *parent):
|
||||||
todosActiveCountChanged,
|
todosActiveCountChanged,
|
||||||
todosCountChanged,
|
todosCountChanged,
|
||||||
[](const Todos* o) {
|
[](const Todos* o) {
|
||||||
emit o->newDataReady(QModelIndex());
|
Q_EMIT o->newDataReady(QModelIndex());
|
||||||
|
},
|
||||||
|
[](Todos* o) {
|
||||||
|
Q_EMIT o->layoutAboutToBeChanged();
|
||||||
|
},
|
||||||
|
[](Todos* o) {
|
||||||
|
o->updatePersistentIndexes();
|
||||||
|
Q_EMIT o->layoutChanged();
|
||||||
},
|
},
|
||||||
[](Todos* o, quintptr first, quintptr last) {
|
[](Todos* o, quintptr first, quintptr last) {
|
||||||
o->dataChanged(o->createIndex(first, 0, first),
|
o->dataChanged(o->createIndex(first, 0, first),
|
||||||
|
@ -264,6 +277,12 @@ Todos::Todos(QObject *parent):
|
||||||
[](Todos* o) {
|
[](Todos* o) {
|
||||||
o->endInsertRows();
|
o->endInsertRows();
|
||||||
},
|
},
|
||||||
|
[](Todos* o, int first, int last, int destination) {
|
||||||
|
o->beginMoveRows(QModelIndex(), first, last, QModelIndex(), destination);
|
||||||
|
},
|
||||||
|
[](Todos* o) {
|
||||||
|
o->endMoveRows();
|
||||||
|
},
|
||||||
[](Todos* o, int first, int last) {
|
[](Todos* o, int first, int last) {
|
||||||
o->beginRemoveRows(QModelIndex(), first, last);
|
o->beginRemoveRows(QModelIndex(), first, last);
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#ifndef BINDINGS_H
|
#ifndef BINDINGS_H
|
||||||
#define BINDINGS_H
|
#define BINDINGS_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QAbstractItemModel>
|
#include <QtCore/QAbstractItemModel>
|
||||||
|
|
||||||
class Todos;
|
class Todos;
|
||||||
|
|
||||||
|
@ -50,13 +50,14 @@ public:
|
||||||
Q_INVOKABLE QString description(int row) const;
|
Q_INVOKABLE QString description(int row) const;
|
||||||
Q_INVOKABLE bool setDescription(int row, const QString& value);
|
Q_INVOKABLE bool setDescription(int row, const QString& value);
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
// new data is ready to be made available to the model with fetchMore()
|
// new data is ready to be made available to the model with fetchMore()
|
||||||
void newDataReady(const QModelIndex &parent) const;
|
void newDataReady(const QModelIndex &parent) const;
|
||||||
private:
|
private:
|
||||||
QHash<QPair<int,Qt::ItemDataRole>, QVariant> m_headerData;
|
QHash<QPair<int,Qt::ItemDataRole>, QVariant> m_headerData;
|
||||||
void initHeaderData();
|
void initHeaderData();
|
||||||
signals:
|
void updatePersistentIndexes();
|
||||||
|
Q_SIGNALS:
|
||||||
void activeCountChanged();
|
void activeCountChanged();
|
||||||
void countChanged();
|
void countChanged();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
/* generated by rust_qt_binding_generator */
|
/* generated by rust_qt_binding_generator */
|
||||||
#![allow(unknown_lints)]
|
|
||||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
|
||||||
use libc::{c_char, c_ushort, c_int};
|
use libc::{c_char, c_ushort, c_int};
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::char::decode_utf16;
|
use std::char::decode_utf16;
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||||
use std::ptr::null;
|
use std::ptr::null;
|
||||||
|
|
||||||
use implementation::*;
|
use implementation::*;
|
||||||
|
@ -16,7 +15,6 @@ pub enum QString {}
|
||||||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
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 utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||||
let characters = decode_utf16(utf16.iter().cloned())
|
let characters = decode_utf16(utf16.iter().cloned())
|
||||||
.into_iter()
|
|
||||||
.map(|r| r.unwrap());
|
.map(|r| r.unwrap());
|
||||||
s.clear();
|
s.clear();
|
||||||
s.extend(characters);
|
s.extend(characters);
|
||||||
|
@ -42,20 +40,32 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct SimpleQObject {}
|
pub struct SimpleQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct SimpleEmitter {
|
pub struct SimpleEmitter {
|
||||||
qobject: Arc<Mutex<*const SimpleQObject>>,
|
qobject: Arc<AtomicPtr<SimpleQObject>>,
|
||||||
message_changed: fn(*const SimpleQObject),
|
message_changed: fn(*mut SimpleQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for SimpleEmitter {}
|
unsafe impl Send for SimpleEmitter {}
|
||||||
|
|
||||||
impl SimpleEmitter {
|
impl SimpleEmitter {
|
||||||
fn clear(&self) {
|
/// Clone the emitter
|
||||||
*self.qobject.lock().unwrap() = null();
|
///
|
||||||
|
/// 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) -> SimpleEmitter {
|
||||||
|
SimpleEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
message_changed: self.message_changed,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn message_changed(&self) {
|
fn clear(&self) {
|
||||||
let ptr = *self.qobject.lock().unwrap();
|
let n: *const SimpleQObject = null();
|
||||||
|
self.qobject.store(n as *mut SimpleQObject, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
pub fn message_changed(&mut self) {
|
||||||
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.message_changed)(ptr);
|
(self.message_changed)(ptr);
|
||||||
}
|
}
|
||||||
|
@ -72,10 +82,10 @@ pub trait SimpleTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn simple_new(
|
pub extern "C" fn simple_new(
|
||||||
simple: *mut SimpleQObject,
|
simple: *mut SimpleQObject,
|
||||||
simple_message_changed: fn(*const SimpleQObject),
|
simple_message_changed: fn(*mut SimpleQObject),
|
||||||
) -> *mut Simple {
|
) -> *mut Simple {
|
||||||
let simple_emit = SimpleEmitter {
|
let simple_emit = SimpleEmitter {
|
||||||
qobject: Arc::new(Mutex::new(simple)),
|
qobject: Arc::new(AtomicPtr::new(simple)),
|
||||||
message_changed: simple_message_changed,
|
message_changed: simple_message_changed,
|
||||||
};
|
};
|
||||||
let d_simple = Simple::new(simple_emit);
|
let d_simple = Simple::new(simple_emit);
|
||||||
|
@ -88,20 +98,20 @@ pub unsafe extern "C" fn simple_free(ptr: *mut Simple) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn simple_message_get(
|
pub unsafe extern "C" fn simple_message_get(
|
||||||
ptr: *const Simple,
|
ptr: *const Simple,
|
||||||
p: *mut QString,
|
p: *mut QString,
|
||||||
set: fn(*mut QString, *const c_char, c_int),
|
set: fn(*mut QString, *const c_char, c_int),
|
||||||
) {
|
) {
|
||||||
let o = unsafe { &*ptr };
|
let o = &*ptr;
|
||||||
let v = o.message();
|
let v = o.message();
|
||||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||||
set(p, s, to_c_int(v.len()));
|
set(p, s, to_c_int(v.len()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn simple_message_set(ptr: *mut Simple, v: *const c_ushort, len: c_int) {
|
pub unsafe extern "C" fn simple_message_set(ptr: *mut Simple, v: *const c_ushort, len: c_int) {
|
||||||
let o = unsafe { &mut *ptr };
|
let o = &mut *ptr;
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
set_string_from_utf16(&mut s, v, len);
|
set_string_from_utf16(&mut s, v, len);
|
||||||
o.set_message(s);
|
o.set_message(s);
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace {
|
||||||
}
|
}
|
||||||
inline void simpleMessageChanged(Simple* o)
|
inline void simpleMessageChanged(Simple* o)
|
||||||
{
|
{
|
||||||
emit o->messageChanged();
|
Q_EMIT o->messageChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
|
|
||||||
Simple::Simple(bool /*owned*/, QObject *parent):
|
Simple::Simple(bool /*owned*/, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_d(0),
|
m_d(nullptr),
|
||||||
m_ownsPrivate(false)
|
m_ownsPrivate(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#ifndef BINDINGS_H
|
#ifndef BINDINGS_H
|
||||||
#define BINDINGS_H
|
#define BINDINGS_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QAbstractItemModel>
|
#include <QtCore/QAbstractItemModel>
|
||||||
|
|
||||||
class Simple;
|
class Simple;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public:
|
||||||
~Simple();
|
~Simple();
|
||||||
QString message() const;
|
QString message() const;
|
||||||
void setMessage(const QString& v);
|
void setMessage(const QString& v);
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void messageChanged();
|
void messageChanged();
|
||||||
};
|
};
|
||||||
#endif // BINDINGS_H
|
#endif // BINDINGS_H
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
/* generated by rust_qt_binding_generator */
|
/* generated by rust_qt_binding_generator */
|
||||||
#![allow(unknown_lints)]
|
|
||||||
#![allow(mutex_atomic, needless_pass_by_value)]
|
|
||||||
use libc::{c_char, c_ushort, c_int};
|
use libc::{c_char, c_ushort, c_int};
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::char::decode_utf16;
|
use std::char::decode_utf16;
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::{AtomicPtr, Ordering};
|
||||||
use std::ptr::null;
|
use std::ptr::null;
|
||||||
|
|
||||||
use implementation::*;
|
use implementation::*;
|
||||||
|
@ -16,7 +15,6 @@ pub enum QString {}
|
||||||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
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 utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||||
let characters = decode_utf16(utf16.iter().cloned())
|
let characters = decode_utf16(utf16.iter().cloned())
|
||||||
.into_iter()
|
|
||||||
.map(|r| r.unwrap());
|
.map(|r| r.unwrap());
|
||||||
s.clear();
|
s.clear();
|
||||||
s.extend(characters);
|
s.extend(characters);
|
||||||
|
@ -42,20 +40,32 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct SimpleQObject {}
|
pub struct SimpleQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct SimpleEmitter {
|
pub struct SimpleEmitter {
|
||||||
qobject: Arc<Mutex<*const SimpleQObject>>,
|
qobject: Arc<AtomicPtr<SimpleQObject>>,
|
||||||
message_changed: fn(*const SimpleQObject),
|
message_changed: fn(*mut SimpleQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for SimpleEmitter {}
|
unsafe impl Send for SimpleEmitter {}
|
||||||
|
|
||||||
impl SimpleEmitter {
|
impl SimpleEmitter {
|
||||||
fn clear(&self) {
|
/// Clone the emitter
|
||||||
*self.qobject.lock().unwrap() = null();
|
///
|
||||||
|
/// 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) -> SimpleEmitter {
|
||||||
|
SimpleEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
message_changed: self.message_changed,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn message_changed(&self) {
|
fn clear(&self) {
|
||||||
let ptr = *self.qobject.lock().unwrap();
|
let n: *const SimpleQObject = null();
|
||||||
|
self.qobject.store(n as *mut SimpleQObject, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
pub fn message_changed(&mut self) {
|
||||||
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.message_changed)(ptr);
|
(self.message_changed)(ptr);
|
||||||
}
|
}
|
||||||
|
@ -72,10 +82,10 @@ pub trait SimpleTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn simple_new(
|
pub extern "C" fn simple_new(
|
||||||
simple: *mut SimpleQObject,
|
simple: *mut SimpleQObject,
|
||||||
simple_message_changed: fn(*const SimpleQObject),
|
simple_message_changed: fn(*mut SimpleQObject),
|
||||||
) -> *mut Simple {
|
) -> *mut Simple {
|
||||||
let simple_emit = SimpleEmitter {
|
let simple_emit = SimpleEmitter {
|
||||||
qobject: Arc::new(Mutex::new(simple)),
|
qobject: Arc::new(AtomicPtr::new(simple)),
|
||||||
message_changed: simple_message_changed,
|
message_changed: simple_message_changed,
|
||||||
};
|
};
|
||||||
let d_simple = Simple::new(simple_emit);
|
let d_simple = Simple::new(simple_emit);
|
||||||
|
@ -88,20 +98,20 @@ pub unsafe extern "C" fn simple_free(ptr: *mut Simple) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn simple_message_get(
|
pub unsafe extern "C" fn simple_message_get(
|
||||||
ptr: *const Simple,
|
ptr: *const Simple,
|
||||||
p: *mut QString,
|
p: *mut QString,
|
||||||
set: fn(*mut QString, *const c_char, c_int),
|
set: fn(*mut QString, *const c_char, c_int),
|
||||||
) {
|
) {
|
||||||
let o = unsafe { &*ptr };
|
let o = &*ptr;
|
||||||
let v = o.message();
|
let v = o.message();
|
||||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||||
set(p, s, to_c_int(v.len()));
|
set(p, s, to_c_int(v.len()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn simple_message_set(ptr: *mut Simple, v: *const c_ushort, len: c_int) {
|
pub unsafe extern "C" fn simple_message_set(ptr: *mut Simple, v: *const c_ushort, len: c_int) {
|
||||||
let o = unsafe { &mut *ptr };
|
let o = &mut *ptr;
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
set_string_from_utf16(&mut s, v, len);
|
set_string_from_utf16(&mut s, v, len);
|
||||||
o.set_message(s);
|
o.set_message(s);
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace {
|
||||||
}
|
}
|
||||||
inline void simpleMessageChanged(Simple* o)
|
inline void simpleMessageChanged(Simple* o)
|
||||||
{
|
{
|
||||||
emit o->messageChanged();
|
Q_EMIT o->messageChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
|
|
||||||
Simple::Simple(bool /*owned*/, QObject *parent):
|
Simple::Simple(bool /*owned*/, QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_d(0),
|
m_d(nullptr),
|
||||||
m_ownsPrivate(false)
|
m_ownsPrivate(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#ifndef BINDINGS_H
|
#ifndef BINDINGS_H
|
||||||
#define BINDINGS_H
|
#define BINDINGS_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QAbstractItemModel>
|
#include <QtCore/QAbstractItemModel>
|
||||||
|
|
||||||
class Simple;
|
class Simple;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public:
|
||||||
~Simple();
|
~Simple();
|
||||||
QString message() const;
|
QString message() const;
|
||||||
void setMessage(const QString& v);
|
void setMessage(const QString& v);
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void messageChanged();
|
void messageChanged();
|
||||||
};
|
};
|
||||||
#endif // BINDINGS_H
|
#endif // BINDINGS_H
|
||||||
|
|
|
@ -43,20 +43,31 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct PersonQObject {}
|
pub struct PersonQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct PersonEmitter {
|
pub struct PersonEmitter {
|
||||||
qobject: Arc<AtomicPtr<PersonQObject>>,
|
qobject: Arc<AtomicPtr<PersonQObject>>,
|
||||||
user_name_changed: fn(*const PersonQObject),
|
user_name_changed: fn(*mut PersonQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for PersonEmitter {}
|
unsafe impl Send for PersonEmitter {}
|
||||||
|
|
||||||
impl PersonEmitter {
|
impl PersonEmitter {
|
||||||
|
/// 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) -> PersonEmitter {
|
||||||
|
PersonEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
user_name_changed: self.user_name_changed,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const PersonQObject = null();
|
let n: *const PersonQObject = null();
|
||||||
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn user_name_changed(&self) {
|
pub fn user_name_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.user_name_changed)(ptr);
|
(self.user_name_changed)(ptr);
|
||||||
|
@ -80,7 +91,7 @@ pub trait PersonTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn person_new(
|
pub extern "C" fn person_new(
|
||||||
person: *mut PersonQObject,
|
person: *mut PersonQObject,
|
||||||
person_user_name_changed: fn(*const PersonQObject),
|
person_user_name_changed: fn(*mut PersonQObject),
|
||||||
) -> *mut Person {
|
) -> *mut Person {
|
||||||
let person_emit = PersonEmitter {
|
let person_emit = PersonEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(person)),
|
qobject: Arc::new(AtomicPtr::new(person)),
|
||||||
|
|
|
@ -91,20 +91,31 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct NoRoleQObject {}
|
pub struct NoRoleQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct NoRoleEmitter {
|
pub struct NoRoleEmitter {
|
||||||
qobject: Arc<AtomicPtr<NoRoleQObject>>,
|
qobject: Arc<AtomicPtr<NoRoleQObject>>,
|
||||||
new_data_ready: fn(*const NoRoleQObject),
|
new_data_ready: fn(*mut NoRoleQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for NoRoleEmitter {}
|
unsafe impl Send for NoRoleEmitter {}
|
||||||
|
|
||||||
impl NoRoleEmitter {
|
impl NoRoleEmitter {
|
||||||
|
/// 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) -> NoRoleEmitter {
|
||||||
|
NoRoleEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
new_data_ready: self.new_data_ready,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const NoRoleQObject = null();
|
let n: *const NoRoleQObject = null();
|
||||||
self.qobject.store(n as *mut NoRoleQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut NoRoleQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self) {
|
pub fn new_data_ready(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr);
|
(self.new_data_ready)(ptr);
|
||||||
|
@ -114,52 +125,52 @@ impl NoRoleEmitter {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct NoRoleList {
|
pub struct NoRoleList {
|
||||||
qobject: *const NoRoleQObject,
|
qobject: *mut NoRoleQObject,
|
||||||
layout_about_to_be_changed: fn(*const NoRoleQObject),
|
layout_about_to_be_changed: fn(*mut NoRoleQObject),
|
||||||
layout_changed: fn(*const NoRoleQObject),
|
layout_changed: fn(*mut NoRoleQObject),
|
||||||
data_changed: fn(*const NoRoleQObject, usize, usize),
|
data_changed: fn(*mut NoRoleQObject, usize, usize),
|
||||||
begin_reset_model: fn(*const NoRoleQObject),
|
begin_reset_model: fn(*mut NoRoleQObject),
|
||||||
end_reset_model: fn(*const NoRoleQObject),
|
end_reset_model: fn(*mut NoRoleQObject),
|
||||||
begin_insert_rows: fn(*const NoRoleQObject, usize, usize),
|
begin_insert_rows: fn(*mut NoRoleQObject, usize, usize),
|
||||||
end_insert_rows: fn(*const NoRoleQObject),
|
end_insert_rows: fn(*mut NoRoleQObject),
|
||||||
begin_move_rows: fn(*const NoRoleQObject, usize, usize, usize),
|
begin_move_rows: fn(*mut NoRoleQObject, usize, usize, usize),
|
||||||
end_move_rows: fn(*const NoRoleQObject),
|
end_move_rows: fn(*mut NoRoleQObject),
|
||||||
begin_remove_rows: fn(*const NoRoleQObject, usize, usize),
|
begin_remove_rows: fn(*mut NoRoleQObject, usize, usize),
|
||||||
end_remove_rows: fn(*const NoRoleQObject),
|
end_remove_rows: fn(*mut NoRoleQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NoRoleList {
|
impl NoRoleList {
|
||||||
pub fn layout_about_to_be_changed(&self) {
|
pub fn layout_about_to_be_changed(&mut self) {
|
||||||
(self.layout_about_to_be_changed)(self.qobject);
|
(self.layout_about_to_be_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn layout_changed(&self) {
|
pub fn layout_changed(&mut self) {
|
||||||
(self.layout_changed)(self.qobject);
|
(self.layout_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
pub fn data_changed(&mut self, first: usize, last: usize) {
|
||||||
(self.data_changed)(self.qobject, first, last);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, first, last);
|
(self.begin_insert_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_move_rows(&self, first: usize, last: usize, destination: usize) {
|
pub fn begin_move_rows(&mut self, first: usize, last: usize, destination: usize) {
|
||||||
(self.begin_move_rows)(self.qobject, first, last, destination);
|
(self.begin_move_rows)(self.qobject, first, last, destination);
|
||||||
}
|
}
|
||||||
pub fn end_move_rows(&self) {
|
pub fn end_move_rows(&mut self) {
|
||||||
(self.end_move_rows)(self.qobject);
|
(self.end_move_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, first: usize, last: usize) {
|
pub fn begin_remove_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_remove_rows)(self.qobject, first, last);
|
(self.begin_remove_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,18 +195,18 @@ pub trait NoRoleTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn no_role_new(
|
pub extern "C" fn no_role_new(
|
||||||
no_role: *mut NoRoleQObject,
|
no_role: *mut NoRoleQObject,
|
||||||
no_role_new_data_ready: fn(*const NoRoleQObject),
|
no_role_new_data_ready: fn(*mut NoRoleQObject),
|
||||||
no_role_layout_about_to_be_changed: fn(*const NoRoleQObject),
|
no_role_layout_about_to_be_changed: fn(*mut NoRoleQObject),
|
||||||
no_role_layout_changed: fn(*const NoRoleQObject),
|
no_role_layout_changed: fn(*mut NoRoleQObject),
|
||||||
no_role_data_changed: fn(*const NoRoleQObject, usize, usize),
|
no_role_data_changed: fn(*mut NoRoleQObject, usize, usize),
|
||||||
no_role_begin_reset_model: fn(*const NoRoleQObject),
|
no_role_begin_reset_model: fn(*mut NoRoleQObject),
|
||||||
no_role_end_reset_model: fn(*const NoRoleQObject),
|
no_role_end_reset_model: fn(*mut NoRoleQObject),
|
||||||
no_role_begin_insert_rows: fn(*const NoRoleQObject, usize, usize),
|
no_role_begin_insert_rows: fn(*mut NoRoleQObject, usize, usize),
|
||||||
no_role_end_insert_rows: fn(*const NoRoleQObject),
|
no_role_end_insert_rows: fn(*mut NoRoleQObject),
|
||||||
no_role_begin_move_rows: fn(*const NoRoleQObject, usize, usize, usize),
|
no_role_begin_move_rows: fn(*mut NoRoleQObject, usize, usize, usize),
|
||||||
no_role_end_move_rows: fn(*const NoRoleQObject),
|
no_role_end_move_rows: fn(*mut NoRoleQObject),
|
||||||
no_role_begin_remove_rows: fn(*const NoRoleQObject, usize, usize),
|
no_role_begin_remove_rows: fn(*mut NoRoleQObject, usize, usize),
|
||||||
no_role_end_remove_rows: fn(*const NoRoleQObject),
|
no_role_end_remove_rows: fn(*mut NoRoleQObject),
|
||||||
) -> *mut NoRole {
|
) -> *mut NoRole {
|
||||||
let no_role_emit = NoRoleEmitter {
|
let no_role_emit = NoRoleEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(no_role)),
|
qobject: Arc::new(AtomicPtr::new(no_role)),
|
||||||
|
@ -292,20 +303,31 @@ pub unsafe extern "C" fn no_role_set_data_user_name(
|
||||||
|
|
||||||
pub struct PersonsQObject {}
|
pub struct PersonsQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct PersonsEmitter {
|
pub struct PersonsEmitter {
|
||||||
qobject: Arc<AtomicPtr<PersonsQObject>>,
|
qobject: Arc<AtomicPtr<PersonsQObject>>,
|
||||||
new_data_ready: fn(*const PersonsQObject),
|
new_data_ready: fn(*mut PersonsQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for PersonsEmitter {}
|
unsafe impl Send for PersonsEmitter {}
|
||||||
|
|
||||||
impl PersonsEmitter {
|
impl PersonsEmitter {
|
||||||
|
/// 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) -> PersonsEmitter {
|
||||||
|
PersonsEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
new_data_ready: self.new_data_ready,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const PersonsQObject = null();
|
let n: *const PersonsQObject = null();
|
||||||
self.qobject.store(n as *mut PersonsQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut PersonsQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self) {
|
pub fn new_data_ready(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr);
|
(self.new_data_ready)(ptr);
|
||||||
|
@ -315,52 +337,52 @@ impl PersonsEmitter {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PersonsList {
|
pub struct PersonsList {
|
||||||
qobject: *const PersonsQObject,
|
qobject: *mut PersonsQObject,
|
||||||
layout_about_to_be_changed: fn(*const PersonsQObject),
|
layout_about_to_be_changed: fn(*mut PersonsQObject),
|
||||||
layout_changed: fn(*const PersonsQObject),
|
layout_changed: fn(*mut PersonsQObject),
|
||||||
data_changed: fn(*const PersonsQObject, usize, usize),
|
data_changed: fn(*mut PersonsQObject, usize, usize),
|
||||||
begin_reset_model: fn(*const PersonsQObject),
|
begin_reset_model: fn(*mut PersonsQObject),
|
||||||
end_reset_model: fn(*const PersonsQObject),
|
end_reset_model: fn(*mut PersonsQObject),
|
||||||
begin_insert_rows: fn(*const PersonsQObject, usize, usize),
|
begin_insert_rows: fn(*mut PersonsQObject, usize, usize),
|
||||||
end_insert_rows: fn(*const PersonsQObject),
|
end_insert_rows: fn(*mut PersonsQObject),
|
||||||
begin_move_rows: fn(*const PersonsQObject, usize, usize, usize),
|
begin_move_rows: fn(*mut PersonsQObject, usize, usize, usize),
|
||||||
end_move_rows: fn(*const PersonsQObject),
|
end_move_rows: fn(*mut PersonsQObject),
|
||||||
begin_remove_rows: fn(*const PersonsQObject, usize, usize),
|
begin_remove_rows: fn(*mut PersonsQObject, usize, usize),
|
||||||
end_remove_rows: fn(*const PersonsQObject),
|
end_remove_rows: fn(*mut PersonsQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PersonsList {
|
impl PersonsList {
|
||||||
pub fn layout_about_to_be_changed(&self) {
|
pub fn layout_about_to_be_changed(&mut self) {
|
||||||
(self.layout_about_to_be_changed)(self.qobject);
|
(self.layout_about_to_be_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn layout_changed(&self) {
|
pub fn layout_changed(&mut self) {
|
||||||
(self.layout_changed)(self.qobject);
|
(self.layout_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
pub fn data_changed(&mut self, first: usize, last: usize) {
|
||||||
(self.data_changed)(self.qobject, first, last);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, first, last);
|
(self.begin_insert_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_move_rows(&self, first: usize, last: usize, destination: usize) {
|
pub fn begin_move_rows(&mut self, first: usize, last: usize, destination: usize) {
|
||||||
(self.begin_move_rows)(self.qobject, first, last, destination);
|
(self.begin_move_rows)(self.qobject, first, last, destination);
|
||||||
}
|
}
|
||||||
pub fn end_move_rows(&self) {
|
pub fn end_move_rows(&mut self) {
|
||||||
(self.end_move_rows)(self.qobject);
|
(self.end_move_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, first: usize, last: usize) {
|
pub fn begin_remove_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_remove_rows)(self.qobject, first, last);
|
(self.begin_remove_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,18 +405,18 @@ pub trait PersonsTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn persons_new(
|
pub extern "C" fn persons_new(
|
||||||
persons: *mut PersonsQObject,
|
persons: *mut PersonsQObject,
|
||||||
persons_new_data_ready: fn(*const PersonsQObject),
|
persons_new_data_ready: fn(*mut PersonsQObject),
|
||||||
persons_layout_about_to_be_changed: fn(*const PersonsQObject),
|
persons_layout_about_to_be_changed: fn(*mut PersonsQObject),
|
||||||
persons_layout_changed: fn(*const PersonsQObject),
|
persons_layout_changed: fn(*mut PersonsQObject),
|
||||||
persons_data_changed: fn(*const PersonsQObject, usize, usize),
|
persons_data_changed: fn(*mut PersonsQObject, usize, usize),
|
||||||
persons_begin_reset_model: fn(*const PersonsQObject),
|
persons_begin_reset_model: fn(*mut PersonsQObject),
|
||||||
persons_end_reset_model: fn(*const PersonsQObject),
|
persons_end_reset_model: fn(*mut PersonsQObject),
|
||||||
persons_begin_insert_rows: fn(*const PersonsQObject, usize, usize),
|
persons_begin_insert_rows: fn(*mut PersonsQObject, usize, usize),
|
||||||
persons_end_insert_rows: fn(*const PersonsQObject),
|
persons_end_insert_rows: fn(*mut PersonsQObject),
|
||||||
persons_begin_move_rows: fn(*const PersonsQObject, usize, usize, usize),
|
persons_begin_move_rows: fn(*mut PersonsQObject, usize, usize, usize),
|
||||||
persons_end_move_rows: fn(*const PersonsQObject),
|
persons_end_move_rows: fn(*mut PersonsQObject),
|
||||||
persons_begin_remove_rows: fn(*const PersonsQObject, usize, usize),
|
persons_begin_remove_rows: fn(*mut PersonsQObject, usize, usize),
|
||||||
persons_end_remove_rows: fn(*const PersonsQObject),
|
persons_end_remove_rows: fn(*mut PersonsQObject),
|
||||||
) -> *mut Persons {
|
) -> *mut Persons {
|
||||||
let persons_emit = PersonsEmitter {
|
let persons_emit = PersonsEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(persons)),
|
qobject: Arc::new(AtomicPtr::new(persons)),
|
||||||
|
|
|
@ -94,20 +94,31 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct ListQObject {}
|
pub struct ListQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct ListEmitter {
|
pub struct ListEmitter {
|
||||||
qobject: Arc<AtomicPtr<ListQObject>>,
|
qobject: Arc<AtomicPtr<ListQObject>>,
|
||||||
new_data_ready: fn(*const ListQObject),
|
new_data_ready: fn(*mut ListQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for ListEmitter {}
|
unsafe impl Send for ListEmitter {}
|
||||||
|
|
||||||
impl ListEmitter {
|
impl ListEmitter {
|
||||||
|
/// 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) -> ListEmitter {
|
||||||
|
ListEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
new_data_ready: self.new_data_ready,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const ListQObject = null();
|
let n: *const ListQObject = null();
|
||||||
self.qobject.store(n as *mut ListQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut ListQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self) {
|
pub fn new_data_ready(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr);
|
(self.new_data_ready)(ptr);
|
||||||
|
@ -117,52 +128,52 @@ impl ListEmitter {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ListList {
|
pub struct ListList {
|
||||||
qobject: *const ListQObject,
|
qobject: *mut ListQObject,
|
||||||
layout_about_to_be_changed: fn(*const ListQObject),
|
layout_about_to_be_changed: fn(*mut ListQObject),
|
||||||
layout_changed: fn(*const ListQObject),
|
layout_changed: fn(*mut ListQObject),
|
||||||
data_changed: fn(*const ListQObject, usize, usize),
|
data_changed: fn(*mut ListQObject, usize, usize),
|
||||||
begin_reset_model: fn(*const ListQObject),
|
begin_reset_model: fn(*mut ListQObject),
|
||||||
end_reset_model: fn(*const ListQObject),
|
end_reset_model: fn(*mut ListQObject),
|
||||||
begin_insert_rows: fn(*const ListQObject, usize, usize),
|
begin_insert_rows: fn(*mut ListQObject, usize, usize),
|
||||||
end_insert_rows: fn(*const ListQObject),
|
end_insert_rows: fn(*mut ListQObject),
|
||||||
begin_move_rows: fn(*const ListQObject, usize, usize, usize),
|
begin_move_rows: fn(*mut ListQObject, usize, usize, usize),
|
||||||
end_move_rows: fn(*const ListQObject),
|
end_move_rows: fn(*mut ListQObject),
|
||||||
begin_remove_rows: fn(*const ListQObject, usize, usize),
|
begin_remove_rows: fn(*mut ListQObject, usize, usize),
|
||||||
end_remove_rows: fn(*const ListQObject),
|
end_remove_rows: fn(*mut ListQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ListList {
|
impl ListList {
|
||||||
pub fn layout_about_to_be_changed(&self) {
|
pub fn layout_about_to_be_changed(&mut self) {
|
||||||
(self.layout_about_to_be_changed)(self.qobject);
|
(self.layout_about_to_be_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn layout_changed(&self) {
|
pub fn layout_changed(&mut self) {
|
||||||
(self.layout_changed)(self.qobject);
|
(self.layout_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
pub fn data_changed(&mut self, first: usize, last: usize) {
|
||||||
(self.data_changed)(self.qobject, first, last);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, first, last);
|
(self.begin_insert_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_move_rows(&self, first: usize, last: usize, destination: usize) {
|
pub fn begin_move_rows(&mut self, first: usize, last: usize, destination: usize) {
|
||||||
(self.begin_move_rows)(self.qobject, first, last, destination);
|
(self.begin_move_rows)(self.qobject, first, last, destination);
|
||||||
}
|
}
|
||||||
pub fn end_move_rows(&self) {
|
pub fn end_move_rows(&mut self) {
|
||||||
(self.end_move_rows)(self.qobject);
|
(self.end_move_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, first: usize, last: usize) {
|
pub fn begin_remove_rows(&mut self, first: usize, last: usize) {
|
||||||
(self.begin_remove_rows)(self.qobject, first, last);
|
(self.begin_remove_rows)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,18 +226,18 @@ pub trait ListTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn list_new(
|
pub extern "C" fn list_new(
|
||||||
list: *mut ListQObject,
|
list: *mut ListQObject,
|
||||||
list_new_data_ready: fn(*const ListQObject),
|
list_new_data_ready: fn(*mut ListQObject),
|
||||||
list_layout_about_to_be_changed: fn(*const ListQObject),
|
list_layout_about_to_be_changed: fn(*mut ListQObject),
|
||||||
list_layout_changed: fn(*const ListQObject),
|
list_layout_changed: fn(*mut ListQObject),
|
||||||
list_data_changed: fn(*const ListQObject, usize, usize),
|
list_data_changed: fn(*mut ListQObject, usize, usize),
|
||||||
list_begin_reset_model: fn(*const ListQObject),
|
list_begin_reset_model: fn(*mut ListQObject),
|
||||||
list_end_reset_model: fn(*const ListQObject),
|
list_end_reset_model: fn(*mut ListQObject),
|
||||||
list_begin_insert_rows: fn(*const ListQObject, usize, usize),
|
list_begin_insert_rows: fn(*mut ListQObject, usize, usize),
|
||||||
list_end_insert_rows: fn(*const ListQObject),
|
list_end_insert_rows: fn(*mut ListQObject),
|
||||||
list_begin_move_rows: fn(*const ListQObject, usize, usize, usize),
|
list_begin_move_rows: fn(*mut ListQObject, usize, usize, usize),
|
||||||
list_end_move_rows: fn(*const ListQObject),
|
list_end_move_rows: fn(*mut ListQObject),
|
||||||
list_begin_remove_rows: fn(*const ListQObject, usize, usize),
|
list_begin_remove_rows: fn(*mut ListQObject, usize, usize),
|
||||||
list_end_remove_rows: fn(*const ListQObject),
|
list_end_remove_rows: fn(*mut ListQObject),
|
||||||
) -> *mut List {
|
) -> *mut List {
|
||||||
let list_emit = ListEmitter {
|
let list_emit = ListEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(list)),
|
qobject: Arc::new(AtomicPtr::new(list)),
|
||||||
|
|
|
@ -40,20 +40,31 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct PersonQObject {}
|
pub struct PersonQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct PersonEmitter {
|
pub struct PersonEmitter {
|
||||||
qobject: Arc<AtomicPtr<PersonQObject>>,
|
qobject: Arc<AtomicPtr<PersonQObject>>,
|
||||||
user_name_changed: fn(*const PersonQObject),
|
user_name_changed: fn(*mut PersonQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for PersonEmitter {}
|
unsafe impl Send for PersonEmitter {}
|
||||||
|
|
||||||
impl PersonEmitter {
|
impl PersonEmitter {
|
||||||
|
/// 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) -> PersonEmitter {
|
||||||
|
PersonEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
user_name_changed: self.user_name_changed,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const PersonQObject = null();
|
let n: *const PersonQObject = null();
|
||||||
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn user_name_changed(&self) {
|
pub fn user_name_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.user_name_changed)(ptr);
|
(self.user_name_changed)(ptr);
|
||||||
|
@ -71,7 +82,7 @@ pub trait PersonTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn person_new(
|
pub extern "C" fn person_new(
|
||||||
person: *mut PersonQObject,
|
person: *mut PersonQObject,
|
||||||
person_user_name_changed: fn(*const PersonQObject),
|
person_user_name_changed: fn(*mut PersonQObject),
|
||||||
) -> *mut Person {
|
) -> *mut Person {
|
||||||
let person_emit = PersonEmitter {
|
let person_emit = PersonEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(person)),
|
qobject: Arc::new(AtomicPtr::new(person)),
|
||||||
|
|
|
@ -80,139 +80,167 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct ObjectQObject {}
|
pub struct ObjectQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct ObjectEmitter {
|
pub struct ObjectEmitter {
|
||||||
qobject: Arc<AtomicPtr<ObjectQObject>>,
|
qobject: Arc<AtomicPtr<ObjectQObject>>,
|
||||||
boolean_changed: fn(*const ObjectQObject),
|
boolean_changed: fn(*mut ObjectQObject),
|
||||||
bytearray_changed: fn(*const ObjectQObject),
|
bytearray_changed: fn(*mut ObjectQObject),
|
||||||
f32_changed: fn(*const ObjectQObject),
|
f32_changed: fn(*mut ObjectQObject),
|
||||||
f64_changed: fn(*const ObjectQObject),
|
f64_changed: fn(*mut ObjectQObject),
|
||||||
i16_changed: fn(*const ObjectQObject),
|
i16_changed: fn(*mut ObjectQObject),
|
||||||
i32_changed: fn(*const ObjectQObject),
|
i32_changed: fn(*mut ObjectQObject),
|
||||||
i64_changed: fn(*const ObjectQObject),
|
i64_changed: fn(*mut ObjectQObject),
|
||||||
i8_changed: fn(*const ObjectQObject),
|
i8_changed: fn(*mut ObjectQObject),
|
||||||
optional_boolean_changed: fn(*const ObjectQObject),
|
optional_boolean_changed: fn(*mut ObjectQObject),
|
||||||
optional_bytearray_changed: fn(*const ObjectQObject),
|
optional_bytearray_changed: fn(*mut ObjectQObject),
|
||||||
optional_string_changed: fn(*const ObjectQObject),
|
optional_string_changed: fn(*mut ObjectQObject),
|
||||||
optional_u64_changed: fn(*const ObjectQObject),
|
optional_u64_changed: fn(*mut ObjectQObject),
|
||||||
string_changed: fn(*const ObjectQObject),
|
string_changed: fn(*mut ObjectQObject),
|
||||||
string_by_function_changed: fn(*const ObjectQObject),
|
string_by_function_changed: fn(*mut ObjectQObject),
|
||||||
u16_changed: fn(*const ObjectQObject),
|
u16_changed: fn(*mut ObjectQObject),
|
||||||
u32_changed: fn(*const ObjectQObject),
|
u32_changed: fn(*mut ObjectQObject),
|
||||||
u64_changed: fn(*const ObjectQObject),
|
u64_changed: fn(*mut ObjectQObject),
|
||||||
u8_changed: fn(*const ObjectQObject),
|
u8_changed: fn(*mut ObjectQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for ObjectEmitter {}
|
unsafe impl Send for ObjectEmitter {}
|
||||||
|
|
||||||
impl ObjectEmitter {
|
impl ObjectEmitter {
|
||||||
|
/// 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) -> ObjectEmitter {
|
||||||
|
ObjectEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
boolean_changed: self.boolean_changed,
|
||||||
|
bytearray_changed: self.bytearray_changed,
|
||||||
|
f32_changed: self.f32_changed,
|
||||||
|
f64_changed: self.f64_changed,
|
||||||
|
i16_changed: self.i16_changed,
|
||||||
|
i32_changed: self.i32_changed,
|
||||||
|
i64_changed: self.i64_changed,
|
||||||
|
i8_changed: self.i8_changed,
|
||||||
|
optional_boolean_changed: self.optional_boolean_changed,
|
||||||
|
optional_bytearray_changed: self.optional_bytearray_changed,
|
||||||
|
optional_string_changed: self.optional_string_changed,
|
||||||
|
optional_u64_changed: self.optional_u64_changed,
|
||||||
|
string_changed: self.string_changed,
|
||||||
|
string_by_function_changed: self.string_by_function_changed,
|
||||||
|
u16_changed: self.u16_changed,
|
||||||
|
u32_changed: self.u32_changed,
|
||||||
|
u64_changed: self.u64_changed,
|
||||||
|
u8_changed: self.u8_changed,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const ObjectQObject = null();
|
let n: *const ObjectQObject = null();
|
||||||
self.qobject.store(n as *mut ObjectQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut ObjectQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn boolean_changed(&self) {
|
pub fn boolean_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.boolean_changed)(ptr);
|
(self.boolean_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn bytearray_changed(&self) {
|
pub fn bytearray_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.bytearray_changed)(ptr);
|
(self.bytearray_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn f32_changed(&self) {
|
pub fn f32_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.f32_changed)(ptr);
|
(self.f32_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn f64_changed(&self) {
|
pub fn f64_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.f64_changed)(ptr);
|
(self.f64_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn i16_changed(&self) {
|
pub fn i16_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.i16_changed)(ptr);
|
(self.i16_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn i32_changed(&self) {
|
pub fn i32_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.i32_changed)(ptr);
|
(self.i32_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn i64_changed(&self) {
|
pub fn i64_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.i64_changed)(ptr);
|
(self.i64_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn i8_changed(&self) {
|
pub fn i8_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.i8_changed)(ptr);
|
(self.i8_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn optional_boolean_changed(&self) {
|
pub fn optional_boolean_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.optional_boolean_changed)(ptr);
|
(self.optional_boolean_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn optional_bytearray_changed(&self) {
|
pub fn optional_bytearray_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.optional_bytearray_changed)(ptr);
|
(self.optional_bytearray_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn optional_string_changed(&self) {
|
pub fn optional_string_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.optional_string_changed)(ptr);
|
(self.optional_string_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn optional_u64_changed(&self) {
|
pub fn optional_u64_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.optional_u64_changed)(ptr);
|
(self.optional_u64_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn string_changed(&self) {
|
pub fn string_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.string_changed)(ptr);
|
(self.string_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn string_by_function_changed(&self) {
|
pub fn string_by_function_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.string_by_function_changed)(ptr);
|
(self.string_by_function_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn u16_changed(&self) {
|
pub fn u16_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.u16_changed)(ptr);
|
(self.u16_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn u32_changed(&self) {
|
pub fn u32_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.u32_changed)(ptr);
|
(self.u32_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn u64_changed(&self) {
|
pub fn u64_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.u64_changed)(ptr);
|
(self.u64_changed)(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn u8_changed(&self) {
|
pub fn u8_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.u8_changed)(ptr);
|
(self.u8_changed)(ptr);
|
||||||
|
@ -263,24 +291,24 @@ pub trait ObjectTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn object_new(
|
pub extern "C" fn object_new(
|
||||||
object: *mut ObjectQObject,
|
object: *mut ObjectQObject,
|
||||||
object_boolean_changed: fn(*const ObjectQObject),
|
object_boolean_changed: fn(*mut ObjectQObject),
|
||||||
object_bytearray_changed: fn(*const ObjectQObject),
|
object_bytearray_changed: fn(*mut ObjectQObject),
|
||||||
object_f32_changed: fn(*const ObjectQObject),
|
object_f32_changed: fn(*mut ObjectQObject),
|
||||||
object_f64_changed: fn(*const ObjectQObject),
|
object_f64_changed: fn(*mut ObjectQObject),
|
||||||
object_i16_changed: fn(*const ObjectQObject),
|
object_i16_changed: fn(*mut ObjectQObject),
|
||||||
object_i32_changed: fn(*const ObjectQObject),
|
object_i32_changed: fn(*mut ObjectQObject),
|
||||||
object_i64_changed: fn(*const ObjectQObject),
|
object_i64_changed: fn(*mut ObjectQObject),
|
||||||
object_i8_changed: fn(*const ObjectQObject),
|
object_i8_changed: fn(*mut ObjectQObject),
|
||||||
object_optional_boolean_changed: fn(*const ObjectQObject),
|
object_optional_boolean_changed: fn(*mut ObjectQObject),
|
||||||
object_optional_bytearray_changed: fn(*const ObjectQObject),
|
object_optional_bytearray_changed: fn(*mut ObjectQObject),
|
||||||
object_optional_string_changed: fn(*const ObjectQObject),
|
object_optional_string_changed: fn(*mut ObjectQObject),
|
||||||
object_optional_u64_changed: fn(*const ObjectQObject),
|
object_optional_u64_changed: fn(*mut ObjectQObject),
|
||||||
object_string_changed: fn(*const ObjectQObject),
|
object_string_changed: fn(*mut ObjectQObject),
|
||||||
object_string_by_function_changed: fn(*const ObjectQObject),
|
object_string_by_function_changed: fn(*mut ObjectQObject),
|
||||||
object_u16_changed: fn(*const ObjectQObject),
|
object_u16_changed: fn(*mut ObjectQObject),
|
||||||
object_u32_changed: fn(*const ObjectQObject),
|
object_u32_changed: fn(*mut ObjectQObject),
|
||||||
object_u64_changed: fn(*const ObjectQObject),
|
object_u64_changed: fn(*mut ObjectQObject),
|
||||||
object_u8_changed: fn(*const ObjectQObject),
|
object_u8_changed: fn(*mut ObjectQObject),
|
||||||
) -> *mut Object {
|
) -> *mut Object {
|
||||||
let object_emit = ObjectEmitter {
|
let object_emit = ObjectEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(object)),
|
qobject: Arc::new(AtomicPtr::new(object)),
|
||||||
|
|
|
@ -40,7 +40,6 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct GroupQObject {}
|
pub struct GroupQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct GroupEmitter {
|
pub struct GroupEmitter {
|
||||||
qobject: Arc<AtomicPtr<GroupQObject>>,
|
qobject: Arc<AtomicPtr<GroupQObject>>,
|
||||||
}
|
}
|
||||||
|
@ -48,6 +47,17 @@ pub struct GroupEmitter {
|
||||||
unsafe impl Send for GroupEmitter {}
|
unsafe impl Send for GroupEmitter {}
|
||||||
|
|
||||||
impl GroupEmitter {
|
impl GroupEmitter {
|
||||||
|
/// 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) -> GroupEmitter {
|
||||||
|
GroupEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const GroupQObject = null();
|
let n: *const GroupQObject = null();
|
||||||
self.qobject.store(n as *mut GroupQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut GroupQObject, Ordering::SeqCst);
|
||||||
|
@ -67,7 +77,7 @@ pub extern "C" fn group_new(
|
||||||
group: *mut GroupQObject,
|
group: *mut GroupQObject,
|
||||||
person: *mut PersonQObject,
|
person: *mut PersonQObject,
|
||||||
object: *mut InnerObjectQObject,
|
object: *mut InnerObjectQObject,
|
||||||
object_description_changed: fn(*const InnerObjectQObject),
|
object_description_changed: fn(*mut InnerObjectQObject),
|
||||||
) -> *mut Group {
|
) -> *mut Group {
|
||||||
let object_emit = InnerObjectEmitter {
|
let object_emit = InnerObjectEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(object)),
|
qobject: Arc::new(AtomicPtr::new(object)),
|
||||||
|
@ -99,20 +109,31 @@ pub unsafe extern "C" fn group_person_get(ptr: *mut Group) -> *mut Person {
|
||||||
|
|
||||||
pub struct InnerObjectQObject {}
|
pub struct InnerObjectQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct InnerObjectEmitter {
|
pub struct InnerObjectEmitter {
|
||||||
qobject: Arc<AtomicPtr<InnerObjectQObject>>,
|
qobject: Arc<AtomicPtr<InnerObjectQObject>>,
|
||||||
description_changed: fn(*const InnerObjectQObject),
|
description_changed: fn(*mut InnerObjectQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for InnerObjectEmitter {}
|
unsafe impl Send for InnerObjectEmitter {}
|
||||||
|
|
||||||
impl InnerObjectEmitter {
|
impl InnerObjectEmitter {
|
||||||
|
/// 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) -> InnerObjectEmitter {
|
||||||
|
InnerObjectEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
description_changed: self.description_changed,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const InnerObjectQObject = null();
|
let n: *const InnerObjectQObject = null();
|
||||||
self.qobject.store(n as *mut InnerObjectQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut InnerObjectQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn description_changed(&self) {
|
pub fn description_changed(&mut self) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.description_changed)(ptr);
|
(self.description_changed)(ptr);
|
||||||
|
@ -130,7 +151,7 @@ pub trait InnerObjectTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn inner_object_new(
|
pub extern "C" fn inner_object_new(
|
||||||
inner_object: *mut InnerObjectQObject,
|
inner_object: *mut InnerObjectQObject,
|
||||||
inner_object_description_changed: fn(*const InnerObjectQObject),
|
inner_object_description_changed: fn(*mut InnerObjectQObject),
|
||||||
) -> *mut InnerObject {
|
) -> *mut InnerObject {
|
||||||
let inner_object_emit = InnerObjectEmitter {
|
let inner_object_emit = InnerObjectEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(inner_object)),
|
qobject: Arc::new(AtomicPtr::new(inner_object)),
|
||||||
|
@ -167,7 +188,6 @@ pub unsafe extern "C" fn inner_object_description_set(ptr: *mut InnerObject, v:
|
||||||
|
|
||||||
pub struct PersonQObject {}
|
pub struct PersonQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct PersonEmitter {
|
pub struct PersonEmitter {
|
||||||
qobject: Arc<AtomicPtr<PersonQObject>>,
|
qobject: Arc<AtomicPtr<PersonQObject>>,
|
||||||
}
|
}
|
||||||
|
@ -175,6 +195,17 @@ pub struct PersonEmitter {
|
||||||
unsafe impl Send for PersonEmitter {}
|
unsafe impl Send for PersonEmitter {}
|
||||||
|
|
||||||
impl PersonEmitter {
|
impl PersonEmitter {
|
||||||
|
/// 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) -> PersonEmitter {
|
||||||
|
PersonEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const PersonQObject = null();
|
let n: *const PersonQObject = null();
|
||||||
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut PersonQObject, Ordering::SeqCst);
|
||||||
|
@ -193,7 +224,7 @@ pub trait PersonTrait {
|
||||||
pub extern "C" fn person_new(
|
pub extern "C" fn person_new(
|
||||||
person: *mut PersonQObject,
|
person: *mut PersonQObject,
|
||||||
object: *mut InnerObjectQObject,
|
object: *mut InnerObjectQObject,
|
||||||
object_description_changed: fn(*const InnerObjectQObject),
|
object_description_changed: fn(*mut InnerObjectQObject),
|
||||||
) -> *mut Person {
|
) -> *mut Person {
|
||||||
let object_emit = InnerObjectEmitter {
|
let object_emit = InnerObjectEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(object)),
|
qobject: Arc::new(AtomicPtr::new(object)),
|
||||||
|
|
|
@ -91,20 +91,31 @@ fn to_c_int(n: usize) -> c_int {
|
||||||
|
|
||||||
pub struct PersonsQObject {}
|
pub struct PersonsQObject {}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct PersonsEmitter {
|
pub struct PersonsEmitter {
|
||||||
qobject: Arc<AtomicPtr<PersonsQObject>>,
|
qobject: Arc<AtomicPtr<PersonsQObject>>,
|
||||||
new_data_ready: fn(*const PersonsQObject, index: COption<usize>),
|
new_data_ready: fn(*mut PersonsQObject, index: COption<usize>),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for PersonsEmitter {}
|
unsafe impl Send for PersonsEmitter {}
|
||||||
|
|
||||||
impl PersonsEmitter {
|
impl PersonsEmitter {
|
||||||
|
/// 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) -> PersonsEmitter {
|
||||||
|
PersonsEmitter {
|
||||||
|
qobject: self.qobject.clone(),
|
||||||
|
new_data_ready: self.new_data_ready,
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clear(&self) {
|
fn clear(&self) {
|
||||||
let n: *const PersonsQObject = null();
|
let n: *const PersonsQObject = null();
|
||||||
self.qobject.store(n as *mut PersonsQObject, Ordering::SeqCst);
|
self.qobject.store(n as *mut PersonsQObject, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
pub fn new_data_ready(&self, item: Option<usize>) {
|
pub fn new_data_ready(&mut self, item: Option<usize>) {
|
||||||
let ptr = self.qobject.load(Ordering::SeqCst);
|
let ptr = self.qobject.load(Ordering::SeqCst);
|
||||||
if !ptr.is_null() {
|
if !ptr.is_null() {
|
||||||
(self.new_data_ready)(ptr, item.into());
|
(self.new_data_ready)(ptr, item.into());
|
||||||
|
@ -114,52 +125,52 @@ impl PersonsEmitter {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PersonsTree {
|
pub struct PersonsTree {
|
||||||
qobject: *const PersonsQObject,
|
qobject: *mut PersonsQObject,
|
||||||
layout_about_to_be_changed: fn(*const PersonsQObject),
|
layout_about_to_be_changed: fn(*mut PersonsQObject),
|
||||||
layout_changed: fn(*const PersonsQObject),
|
layout_changed: fn(*mut PersonsQObject),
|
||||||
data_changed: fn(*const PersonsQObject, usize, usize),
|
data_changed: fn(*mut PersonsQObject, usize, usize),
|
||||||
begin_reset_model: fn(*const PersonsQObject),
|
begin_reset_model: fn(*mut PersonsQObject),
|
||||||
end_reset_model: fn(*const PersonsQObject),
|
end_reset_model: fn(*mut PersonsQObject),
|
||||||
begin_insert_rows: fn(*const PersonsQObject, index: COption<usize>, usize, usize),
|
begin_insert_rows: fn(*mut PersonsQObject, index: COption<usize>, usize, usize),
|
||||||
end_insert_rows: fn(*const PersonsQObject),
|
end_insert_rows: fn(*mut PersonsQObject),
|
||||||
begin_move_rows: fn(*const PersonsQObject, index: COption<usize>, usize, usize, dest: COption<usize>, usize),
|
begin_move_rows: fn(*mut PersonsQObject, index: COption<usize>, usize, usize, dest: COption<usize>, usize),
|
||||||
end_move_rows: fn(*const PersonsQObject),
|
end_move_rows: fn(*mut PersonsQObject),
|
||||||
begin_remove_rows: fn(*const PersonsQObject, index: COption<usize>, usize, usize),
|
begin_remove_rows: fn(*mut PersonsQObject, index: COption<usize>, usize, usize),
|
||||||
end_remove_rows: fn(*const PersonsQObject),
|
end_remove_rows: fn(*mut PersonsQObject),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PersonsTree {
|
impl PersonsTree {
|
||||||
pub fn layout_about_to_be_changed(&self) {
|
pub fn layout_about_to_be_changed(&mut self) {
|
||||||
(self.layout_about_to_be_changed)(self.qobject);
|
(self.layout_about_to_be_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn layout_changed(&self) {
|
pub fn layout_changed(&mut self) {
|
||||||
(self.layout_changed)(self.qobject);
|
(self.layout_changed)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn data_changed(&self, first: usize, last: usize) {
|
pub fn data_changed(&mut self, first: usize, last: usize) {
|
||||||
(self.data_changed)(self.qobject, first, last);
|
(self.data_changed)(self.qobject, first, last);
|
||||||
}
|
}
|
||||||
pub fn begin_reset_model(&self) {
|
pub fn begin_reset_model(&mut self) {
|
||||||
(self.begin_reset_model)(self.qobject);
|
(self.begin_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn end_reset_model(&self) {
|
pub fn end_reset_model(&mut self) {
|
||||||
(self.end_reset_model)(self.qobject);
|
(self.end_reset_model)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_insert_rows(&self, index: Option<usize>, first: usize, last: usize) {
|
pub fn begin_insert_rows(&mut self, index: Option<usize>, first: usize, last: usize) {
|
||||||
(self.begin_insert_rows)(self.qobject, index.into(), first, last);
|
(self.begin_insert_rows)(self.qobject, index.into(), first, last);
|
||||||
}
|
}
|
||||||
pub fn end_insert_rows(&self) {
|
pub fn end_insert_rows(&mut self) {
|
||||||
(self.end_insert_rows)(self.qobject);
|
(self.end_insert_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_move_rows(&self, index: Option<usize>, first: usize, last: usize, dest: Option<usize>, destination: usize) {
|
pub fn begin_move_rows(&mut self, index: Option<usize>, first: usize, last: usize, dest: Option<usize>, destination: usize) {
|
||||||
(self.begin_move_rows)(self.qobject, index.into(), first, last, dest.into(), destination);
|
(self.begin_move_rows)(self.qobject, index.into(), first, last, dest.into(), destination);
|
||||||
}
|
}
|
||||||
pub fn end_move_rows(&self) {
|
pub fn end_move_rows(&mut self) {
|
||||||
(self.end_move_rows)(self.qobject);
|
(self.end_move_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
pub fn begin_remove_rows(&self, index: Option<usize>, first: usize, last: usize) {
|
pub fn begin_remove_rows(&mut self, index: Option<usize>, first: usize, last: usize) {
|
||||||
(self.begin_remove_rows)(self.qobject, index.into(), first, last);
|
(self.begin_remove_rows)(self.qobject, index.into(), first, last);
|
||||||
}
|
}
|
||||||
pub fn end_remove_rows(&self) {
|
pub fn end_remove_rows(&mut self) {
|
||||||
(self.end_remove_rows)(self.qobject);
|
(self.end_remove_rows)(self.qobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,18 +195,18 @@ pub trait PersonsTrait {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn persons_new(
|
pub extern "C" fn persons_new(
|
||||||
persons: *mut PersonsQObject,
|
persons: *mut PersonsQObject,
|
||||||
persons_new_data_ready: fn(*const PersonsQObject, index: COption<usize>),
|
persons_new_data_ready: fn(*mut PersonsQObject, index: COption<usize>),
|
||||||
persons_layout_about_to_be_changed: fn(*const PersonsQObject),
|
persons_layout_about_to_be_changed: fn(*mut PersonsQObject),
|
||||||
persons_layout_changed: fn(*const PersonsQObject),
|
persons_layout_changed: fn(*mut PersonsQObject),
|
||||||
persons_data_changed: fn(*const PersonsQObject, usize, usize),
|
persons_data_changed: fn(*mut PersonsQObject, usize, usize),
|
||||||
persons_begin_reset_model: fn(*const PersonsQObject),
|
persons_begin_reset_model: fn(*mut PersonsQObject),
|
||||||
persons_end_reset_model: fn(*const PersonsQObject),
|
persons_end_reset_model: fn(*mut PersonsQObject),
|
||||||
persons_begin_insert_rows: fn(*const PersonsQObject, index: COption<usize>, usize, usize),
|
persons_begin_insert_rows: fn(*mut PersonsQObject, index: COption<usize>, usize, usize),
|
||||||
persons_end_insert_rows: fn(*const PersonsQObject),
|
persons_end_insert_rows: fn(*mut PersonsQObject),
|
||||||
persons_begin_move_rows: fn(*const PersonsQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
persons_begin_move_rows: fn(*mut PersonsQObject, index: COption<usize>, usize, usize, index: COption<usize>, usize),
|
||||||
persons_end_move_rows: fn(*const PersonsQObject),
|
persons_end_move_rows: fn(*mut PersonsQObject),
|
||||||
persons_begin_remove_rows: fn(*const PersonsQObject, index: COption<usize>, usize, usize),
|
persons_begin_remove_rows: fn(*mut PersonsQObject, index: COption<usize>, usize, usize),
|
||||||
persons_end_remove_rows: fn(*const PersonsQObject),
|
persons_end_remove_rows: fn(*mut PersonsQObject),
|
||||||
) -> *mut Persons {
|
) -> *mut Persons {
|
||||||
let persons_emit = PersonsEmitter {
|
let persons_emit = PersonsEmitter {
|
||||||
qobject: Arc::new(AtomicPtr::new(persons)),
|
qobject: Arc::new(AtomicPtr::new(persons)),
|
||||||
|
|
Loading…
Reference in New Issue