Fix some clippy issues in written and generated code
parent
9549c50217
commit
0192124c70
|
@ -36,12 +36,12 @@ impl DemoTrait for Demo {
|
|||
processes: Processes,
|
||||
time_series: TimeSeries) -> Self {
|
||||
Demo {
|
||||
emit: emit,
|
||||
fibonacci: fibonacci,
|
||||
fibonacci_list: fibonacci_list,
|
||||
file_system_tree: file_system_tree,
|
||||
processes: processes,
|
||||
time_series: time_series
|
||||
emit,
|
||||
fibonacci,
|
||||
fibonacci_list,
|
||||
file_system_tree,
|
||||
processes,
|
||||
time_series
|
||||
}
|
||||
}
|
||||
fn emit(&self) -> &DemoEmitter {
|
||||
|
|
|
@ -48,7 +48,7 @@ pub struct Fibonacci {
|
|||
impl FibonacciTrait for Fibonacci {
|
||||
fn new(emit: FibonacciEmitter) -> Fibonacci {
|
||||
Fibonacci {
|
||||
emit: emit,
|
||||
emit,
|
||||
input: 0,
|
||||
result: Arc::new(AtomicUsize::new(0)),
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ pub struct FibonacciList {
|
|||
impl FibonacciListTrait for FibonacciList {
|
||||
fn new(emit: FibonacciListEmitter, _: FibonacciListList) -> FibonacciList {
|
||||
FibonacciList {
|
||||
emit: emit,
|
||||
emit,
|
||||
}
|
||||
}
|
||||
fn emit(&self) -> &FibonacciListEmitter {
|
||||
|
|
|
@ -209,8 +209,8 @@ where
|
|||
{
|
||||
fn new(emit: FileSystemTreeEmitter, model: FileSystemTreeTree) -> Self {
|
||||
let mut tree = RGeneralItemModel {
|
||||
emit: emit,
|
||||
model: model,
|
||||
emit,
|
||||
model,
|
||||
entries: Vec::new(),
|
||||
path: None,
|
||||
incoming: Arc::new(Mutex::new(HashMap::new())),
|
||||
|
|
|
@ -56,7 +56,7 @@ pub struct Processes {
|
|||
fn check_process_hierarchy(parent: Option<pid_t>, processes: &HashMap<pid_t, Process>) {
|
||||
for (pid, process) in processes {
|
||||
assert_eq!(process.pid, *pid);
|
||||
if !parent.is_none() {
|
||||
if parent.is_some() {
|
||||
assert_eq!(process.parent, parent);
|
||||
}
|
||||
check_process_hierarchy(Some(*pid), &process.tasks);
|
||||
|
@ -325,7 +325,7 @@ impl ProcessesTrait for Processes {
|
|||
let (tx, rx) = channel();
|
||||
let p = Processes {
|
||||
emit: emit.clone(),
|
||||
model: model,
|
||||
model,
|
||||
p: ProcessTree::default(),
|
||||
incoming: Arc::new(Mutex::new(None)),
|
||||
active: false,
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct TimeSeries {
|
|||
impl TimeSeriesTrait for TimeSeries {
|
||||
fn new(emit: TimeSeriesEmitter, _: TimeSeriesList) -> TimeSeries {
|
||||
let mut series = TimeSeries {
|
||||
emit: emit,
|
||||
emit,
|
||||
list: Vec::new(),
|
||||
};
|
||||
for i in 0..101 {
|
||||
|
|
|
@ -53,7 +53,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
@ -550,14 +549,14 @@ pub unsafe extern "C" fn fibonacci_list_sort(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn fibonacci_list_data_fibonacci_number(ptr: *const FibonacciList, row: c_int) -> u64 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn fibonacci_list_data_fibonacci_number(ptr: *const FibonacciList, row: c_int) -> u64 {
|
||||
let o = &*ptr;
|
||||
o.fibonacci_number(to_usize(row)).into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn fibonacci_list_data_row(ptr: *const FibonacciList, row: c_int) -> u64 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn fibonacci_list_data_row(ptr: *const FibonacciList, row: c_int) -> u64 {
|
||||
let o = &*ptr;
|
||||
o.row(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -711,12 +710,12 @@ pub unsafe extern "C" fn file_system_tree_free(ptr: *mut FileSystemTree) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_path_get(
|
||||
pub unsafe extern "C" fn file_system_tree_path_get(
|
||||
ptr: *const FileSystemTree,
|
||||
p: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.path();
|
||||
if let Some(v) = v {
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
|
@ -725,16 +724,16 @@ pub extern "C" fn file_system_tree_path_get(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_path_set(ptr: *mut FileSystemTree, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn file_system_tree_path_set(ptr: *mut FileSystemTree, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_path(Some(s));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_path_set_none(ptr: *mut FileSystemTree) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn file_system_tree_path_set_none(ptr: *mut FileSystemTree) {
|
||||
let o = &mut *ptr;
|
||||
o.set_path(None);
|
||||
}
|
||||
|
||||
|
@ -800,36 +799,36 @@ pub unsafe extern "C" fn file_system_tree_row(ptr: *const FileSystemTree, index:
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_data_file_icon(
|
||||
pub unsafe extern "C" fn file_system_tree_data_file_icon(
|
||||
ptr: *const FileSystemTree, index: usize,
|
||||
d: *mut QByteArray,
|
||||
set: fn(*mut QByteArray, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.file_icon(index);
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_data_file_name(
|
||||
pub unsafe extern "C" fn file_system_tree_data_file_name(
|
||||
ptr: *const FileSystemTree, index: usize,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.file_name(index);
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_data_file_path(
|
||||
pub unsafe extern "C" fn file_system_tree_data_file_path(
|
||||
ptr: *const FileSystemTree, index: usize,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.file_path(index);
|
||||
if let Some(data) = data {
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
|
@ -838,20 +837,20 @@ pub extern "C" fn file_system_tree_data_file_path(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_data_file_permissions(ptr: *const FileSystemTree, index: usize) -> i32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn file_system_tree_data_file_permissions(ptr: *const FileSystemTree, index: usize) -> i32 {
|
||||
let o = &*ptr;
|
||||
o.file_permissions(index).into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_data_file_size(ptr: *const FileSystemTree, index: usize) -> COption<u64> {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn file_system_tree_data_file_size(ptr: *const FileSystemTree, index: usize) -> COption<u64> {
|
||||
let o = &*ptr;
|
||||
o.file_size(index).into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn file_system_tree_data_file_type(ptr: *const FileSystemTree, index: usize) -> i32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn file_system_tree_data_file_type(ptr: *const FileSystemTree, index: usize) -> i32 {
|
||||
let o = &*ptr;
|
||||
o.file_type(index).into()
|
||||
}
|
||||
|
||||
|
@ -1077,56 +1076,56 @@ pub unsafe extern "C" fn processes_row(ptr: *const Processes, index: usize) -> c
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn processes_data_cmd(
|
||||
pub unsafe extern "C" fn processes_data_cmd(
|
||||
ptr: *const Processes, index: usize,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.cmd(index);
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn processes_data_cpu_percentage(ptr: *const Processes, index: usize) -> u8 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn processes_data_cpu_percentage(ptr: *const Processes, index: usize) -> u8 {
|
||||
let o = &*ptr;
|
||||
o.cpu_percentage(index).into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn processes_data_cpu_usage(ptr: *const Processes, index: usize) -> f32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn processes_data_cpu_usage(ptr: *const Processes, index: usize) -> f32 {
|
||||
let o = &*ptr;
|
||||
o.cpu_usage(index).into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn processes_data_memory(ptr: *const Processes, index: usize) -> u64 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn processes_data_memory(ptr: *const Processes, index: usize) -> u64 {
|
||||
let o = &*ptr;
|
||||
o.memory(index).into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn processes_data_name(
|
||||
pub unsafe extern "C" fn processes_data_name(
|
||||
ptr: *const Processes, index: usize,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.name(index);
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn processes_data_pid(ptr: *const Processes, index: usize) -> u32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn processes_data_pid(ptr: *const Processes, index: usize) -> u32 {
|
||||
let o = &*ptr;
|
||||
o.pid(index).into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn processes_data_uid(ptr: *const Processes, index: usize) -> u32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn processes_data_uid(ptr: *const Processes, index: usize) -> u32 {
|
||||
let o = &*ptr;
|
||||
o.uid(index).into()
|
||||
}
|
||||
|
||||
|
@ -1296,8 +1295,8 @@ pub unsafe extern "C" fn time_series_sort(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn time_series_data_cos(ptr: *const TimeSeries, row: c_int) -> f32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn time_series_data_cos(ptr: *const TimeSeries, row: c_int) -> f32 {
|
||||
let o = &*ptr;
|
||||
o.cos(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -1310,8 +1309,8 @@ pub unsafe extern "C" fn time_series_set_data_cos(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn time_series_data_sin(ptr: *const TimeSeries, row: c_int) -> f32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn time_series_data_sin(ptr: *const TimeSeries, row: c_int) -> f32 {
|
||||
let o = &*ptr;
|
||||
o.sin(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -1324,8 +1323,8 @@ pub unsafe extern "C" fn time_series_set_data_sin(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn time_series_data_time(ptr: *const TimeSeries, row: c_int) -> f32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn time_series_data_time(ptr: *const TimeSeries, row: c_int) -> f32 {
|
||||
let o = &*ptr;
|
||||
o.time(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
|
67
src/rust.cpp
67
src/rust.cpp
|
@ -162,7 +162,7 @@ void writeFunction(QTextStream& r, const Function& f, const QString& lcname, con
|
|||
const QString lc(snakeCase(f.name));
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %1_%2(ptr: *%3 %4)").arg(lcname, lc, f.mut ? "mut" : "const", o.name);
|
||||
pub unsafe extern "C" fn %1_%2(ptr: *%3 %4)").arg(lcname, lc, f.mut ? "mut" : "const", o.name);
|
||||
// write all the input arguments, for QString and QByteArray, write
|
||||
// pointers to their content and the length which is int in Qt
|
||||
for (auto a = f.args.begin(); a < f.args.end(); a++) {
|
||||
|
@ -188,13 +188,13 @@ pub extern "C" fn %1_%2(ptr: *%3 %4)").arg(lcname, lc, f.mut ? "mut" : "const",
|
|||
r << " let mut " << a->name << " = String::new();\n";
|
||||
r << QString(" set_string_from_utf16(&mut %1, %1_str, %1_len);\n").arg(a->name);
|
||||
} else if (a->type.name == "QByteArray") {
|
||||
r << QString(" let %1 = unsafe { slice::from_raw_parts(%1_str as *const u8, to_usize(%1_len)) };\n").arg(a->name);
|
||||
r << QString(" let %1 = { slice::from_raw_parts(%1_str as *const u8, to_usize(%1_len)) };\n").arg(a->name);
|
||||
}
|
||||
}
|
||||
if (f.mut) {
|
||||
r << " let o = unsafe { &mut *ptr };\n";
|
||||
r << " let o = &mut *ptr;\n";
|
||||
} else {
|
||||
r << " let o = unsafe { &*ptr };\n";
|
||||
r << " let o = &*ptr;\n";
|
||||
}
|
||||
r << " let r = o." << lc << "(";
|
||||
for (auto a = f.args.begin(); a < f.args.end(); a++) {
|
||||
|
@ -471,12 +471,12 @@ pub unsafe extern "C" fn %2_get(ptr: *mut %1) -> *mut %4 {
|
|||
if (p.rustByFunction) {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_get(
|
||||
pub unsafe extern "C" fn %2_get(
|
||||
ptr: *const %1,
|
||||
p: *mut %4,
|
||||
set: fn(*mut %4, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
o.%3(|v| {
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
set(p, s, to_c_int(v.len()));
|
||||
|
@ -486,12 +486,12 @@ pub extern "C" fn %2_get(
|
|||
} else {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_get(
|
||||
pub unsafe extern "C" fn %2_get(
|
||||
ptr: *const %1,
|
||||
p: *mut %4,
|
||||
set: fn(*mut %4, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.%3();
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
set(p, s, to_c_int(v.len()));
|
||||
|
@ -501,8 +501,8 @@ pub extern "C" fn %2_get(
|
|||
if (p.write && p.type.name == "QString") {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_set(ptr: *mut %1, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn %2_set(ptr: *mut %1, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_%3(s);
|
||||
|
@ -511,9 +511,9 @@ pub extern "C" fn %2_set(ptr: *mut %1, v: *const c_ushort, len: c_int) {
|
|||
} else if (p.write) {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_set(ptr: *mut %1, v: *const c_char, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let v = unsafe { slice::from_raw_parts(v as *const u8, to_usize(len)) };
|
||||
pub unsafe extern "C" fn %2_set(ptr: *mut %1, v: *const c_char, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let v = slice::from_raw_parts(v as *const u8, to_usize(len));
|
||||
o.set_%3(v);
|
||||
}
|
||||
)").arg(o.name, base, snakeCase(p.name));
|
||||
|
@ -521,12 +521,12 @@ pub extern "C" fn %2_set(ptr: *mut %1, v: *const c_char, len: c_int) {
|
|||
} else if (p.type.isComplex()) {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_get(
|
||||
pub unsafe extern "C" fn %2_get(
|
||||
ptr: *const %1,
|
||||
p: *mut %4,
|
||||
set: fn(*mut %4, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.%3();
|
||||
if let Some(v) = v {
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
|
@ -537,8 +537,8 @@ pub extern "C" fn %2_get(
|
|||
if (p.write && p.type.name == "QString") {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_set(ptr: *mut %1, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn %2_set(ptr: *mut %1, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_%3(Some(s));
|
||||
|
@ -547,9 +547,9 @@ pub extern "C" fn %2_set(ptr: *mut %1, v: *const c_ushort, len: c_int) {
|
|||
} else if (p.write) {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_set(ptr: *mut %1, v: *const c_char, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let v = unsafe { slice::from_raw_parts(v as *const u8, to_usize(len)) };
|
||||
pub unsafe extern "C" fn %2_set(ptr: *mut %1, v: *const c_char, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let v = slice::from_raw_parts(v as *const u8, to_usize(len));
|
||||
o.set_%3(Some(v.into()));
|
||||
}
|
||||
)").arg(o.name, base, snakeCase(p.name));
|
||||
|
@ -591,8 +591,8 @@ pub unsafe extern "C" fn %2_set(ptr: *mut %1, v: %4) {
|
|||
if (p.write && p.optional) {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_set_none(ptr: *mut %1) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn %2_set_none(ptr: *mut %1) {
|
||||
let o = &mut *ptr;
|
||||
o.set_%3(None);
|
||||
}
|
||||
)").arg(o.name, base, snakeCase(p.name));
|
||||
|
@ -707,12 +707,12 @@ pub unsafe extern "C" fn %2_row(ptr: *const %1, index: usize) -> c_int {
|
|||
if (ip.type.isComplex() && !ip.optional) {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_data_%3(
|
||||
pub unsafe extern "C" fn %2_data_%3(
|
||||
ptr: *const %1%4,
|
||||
d: *mut %6,
|
||||
set: fn(*mut %6, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.%3(%5);
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
|
@ -721,12 +721,12 @@ pub extern "C" fn %2_data_%3(
|
|||
} else if (ip.type.isComplex()) {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_data_%3(
|
||||
pub unsafe extern "C" fn %2_data_%3(
|
||||
ptr: *const %1%4,
|
||||
d: *mut %6,
|
||||
set: fn(*mut %6, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.%3(%5);
|
||||
if let Some(data) = data {
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
|
@ -737,8 +737,8 @@ pub extern "C" fn %2_data_%3(
|
|||
} else {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_data_%3(ptr: *const %1%5) -> %4 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn %2_data_%3(ptr: *const %1%5) -> %4 {
|
||||
let o = &*ptr;
|
||||
o.%3(%6).into()
|
||||
}
|
||||
)").arg(o.name, lcname, snakeCase(ip.name), rustCType(ip), indexDecl, index);
|
||||
|
@ -751,11 +751,11 @@ pub extern "C" fn %2_data_%3(ptr: *const %1%5) -> %4 {
|
|||
if (ip.type.name == "QString") {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_set_data_%3(
|
||||
pub unsafe extern "C" fn %2_set_data_%3(
|
||||
ptr: *mut %1%4,
|
||||
s: *const c_ushort, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let o = &mut *ptr;
|
||||
let mut v = String::new();
|
||||
set_string_from_utf16(&mut v, s, len);
|
||||
o.set_%3(%5, %6)
|
||||
|
@ -764,12 +764,12 @@ pub extern "C" fn %2_set_data_%3(
|
|||
} else if (ip.type.name == "QByteArray") {
|
||||
r << QString(R"(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn %2_set_data_%3(
|
||||
pub unsafe extern "C" fn %2_set_data_%3(
|
||||
ptr: *mut %1%4,
|
||||
s: *const c_char, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let slice = unsafe { ::std::slice::from_raw_parts(s as *const u8, to_usize(len)) };
|
||||
let o = &mut *ptr;
|
||||
let slice = ::std::slice::from_raw_parts(s as *const u8, to_usize(len));
|
||||
o.set_%3(%5, %6)
|
||||
}
|
||||
)").arg(o.name, lcname, snakeCase(ip.name), indexDecl, index, ip.optional ?"Some(slice)" :"slice");
|
||||
|
@ -883,7 +883,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
|
|
@ -16,7 +16,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
@ -97,76 +96,76 @@ pub unsafe extern "C" fn person_free(ptr: *mut Person) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_user_name_get(
|
||||
pub unsafe extern "C" fn person_user_name_get(
|
||||
ptr: *const Person,
|
||||
p: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.user_name();
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
set(p, s, to_c_int(v.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_user_name_set(ptr: *mut Person, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn person_user_name_set(ptr: *mut Person, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_user_name(s);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_append(ptr: *mut Person, suffix_str: *const c_ushort, suffix_len: c_int, amount: u32) -> () {
|
||||
pub unsafe extern "C" fn person_append(ptr: *mut Person, suffix_str: *const c_ushort, suffix_len: c_int, amount: u32) -> () {
|
||||
let mut suffix = String::new();
|
||||
set_string_from_utf16(&mut suffix, suffix_str, suffix_len);
|
||||
let o = unsafe { &mut *ptr };
|
||||
let o = &mut *ptr;
|
||||
let r = o.append(suffix, amount);
|
||||
r
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_double_name(ptr: *mut Person) -> () {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn person_double_name(ptr: *mut Person) -> () {
|
||||
let o = &mut *ptr;
|
||||
let r = o.double_name();
|
||||
r
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_greet(ptr: *const Person, name_str: *const c_ushort, name_len: c_int, d: *mut QString, set: fn(*mut QString, str: *const c_char, len: c_int)) {
|
||||
pub unsafe extern "C" fn person_greet(ptr: *const Person, name_str: *const c_ushort, name_len: c_int, d: *mut QString, set: fn(*mut QString, str: *const c_char, len: c_int)) {
|
||||
let mut name = String::new();
|
||||
set_string_from_utf16(&mut name, name_str, name_len);
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let r = o.greet(name);
|
||||
let s: *const c_char = r.as_ptr() as (*const c_char);
|
||||
set(d, s, r.len() as i32);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_quote(ptr: *const Person, prefix_str: *const c_ushort, prefix_len: c_int, suffix_str: *const c_ushort, suffix_len: c_int, d: *mut QString, set: fn(*mut QString, str: *const c_char, len: c_int)) {
|
||||
pub unsafe extern "C" fn person_quote(ptr: *const Person, prefix_str: *const c_ushort, prefix_len: c_int, suffix_str: *const c_ushort, suffix_len: c_int, d: *mut QString, set: fn(*mut QString, str: *const c_char, len: c_int)) {
|
||||
let mut prefix = String::new();
|
||||
set_string_from_utf16(&mut prefix, prefix_str, prefix_len);
|
||||
let mut suffix = String::new();
|
||||
set_string_from_utf16(&mut suffix, suffix_str, suffix_len);
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let r = o.quote(prefix, suffix);
|
||||
let s: *const c_char = r.as_ptr() as (*const c_char);
|
||||
set(d, s, r.len() as i32);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_quote_bytes(ptr: *const Person, prefix_str: *const c_char, prefix_len: c_int, suffix_str: *const c_char, suffix_len: c_int, d: *mut QByteArray, set: fn(*mut QByteArray, str: *const c_char, len: c_int)) {
|
||||
let prefix = unsafe { slice::from_raw_parts(prefix_str as *const u8, to_usize(prefix_len)) };
|
||||
let suffix = unsafe { slice::from_raw_parts(suffix_str as *const u8, to_usize(suffix_len)) };
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn person_quote_bytes(ptr: *const Person, prefix_str: *const c_char, prefix_len: c_int, suffix_str: *const c_char, suffix_len: c_int, d: *mut QByteArray, set: fn(*mut QByteArray, str: *const c_char, len: c_int)) {
|
||||
let prefix = { slice::from_raw_parts(prefix_str as *const u8, to_usize(prefix_len)) };
|
||||
let suffix = { slice::from_raw_parts(suffix_str as *const u8, to_usize(suffix_len)) };
|
||||
let o = &*ptr;
|
||||
let r = o.quote_bytes(prefix, suffix);
|
||||
let s: *const c_char = r.as_ptr() as (*const c_char);
|
||||
set(d, s, r.len() as i32);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_vowels_in_name(ptr: *const Person) -> u8 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn person_vowels_in_name(ptr: *const Person) -> u8 {
|
||||
let o = &*ptr;
|
||||
let r = o.vowels_in_name();
|
||||
r
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
@ -255,8 +254,8 @@ pub unsafe extern "C" fn no_role_sort(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn no_role_data_user_age(ptr: *const NoRole, row: c_int) -> u8 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn no_role_data_user_age(ptr: *const NoRole, row: c_int) -> u8 {
|
||||
let o = &*ptr;
|
||||
o.user_age(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -269,23 +268,23 @@ pub unsafe extern "C" fn no_role_set_data_user_age(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn no_role_data_user_name(
|
||||
pub unsafe extern "C" fn no_role_data_user_name(
|
||||
ptr: *const NoRole, row: c_int,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.user_name(to_usize(row));
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn no_role_set_data_user_name(
|
||||
pub unsafe extern "C" fn no_role_set_data_user_name(
|
||||
ptr: *mut NoRole, row: c_int,
|
||||
s: *const c_ushort, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let o = &mut *ptr;
|
||||
let mut v = String::new();
|
||||
set_string_from_utf16(&mut v, s, len);
|
||||
o.set_user_name(to_usize(row), v)
|
||||
|
@ -453,23 +452,23 @@ pub unsafe extern "C" fn persons_sort(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn persons_data_user_name(
|
||||
pub unsafe extern "C" fn persons_data_user_name(
|
||||
ptr: *const Persons, row: c_int,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.user_name(to_usize(row));
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn persons_set_data_user_name(
|
||||
pub unsafe extern "C" fn persons_set_data_user_name(
|
||||
ptr: *mut Persons, row: c_int,
|
||||
s: *const c_ushort, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let o = &mut *ptr;
|
||||
let mut v = String::new();
|
||||
set_string_from_utf16(&mut v, s, len);
|
||||
o.set_user_name(to_usize(row), v)
|
||||
|
|
|
@ -53,7 +53,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
@ -286,8 +285,8 @@ pub unsafe extern "C" fn list_sort(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_boolean(ptr: *const List, row: c_int) -> bool {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_boolean(ptr: *const List, row: c_int) -> bool {
|
||||
let o = &*ptr;
|
||||
o.boolean(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -300,30 +299,30 @@ pub unsafe extern "C" fn list_set_data_boolean(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_bytearray(
|
||||
pub unsafe extern "C" fn list_data_bytearray(
|
||||
ptr: *const List, row: c_int,
|
||||
d: *mut QByteArray,
|
||||
set: fn(*mut QByteArray, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.bytearray(to_usize(row));
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_set_data_bytearray(
|
||||
pub unsafe extern "C" fn list_set_data_bytearray(
|
||||
ptr: *mut List, row: c_int,
|
||||
s: *const c_char, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let slice = unsafe { ::std::slice::from_raw_parts(s as *const u8, to_usize(len)) };
|
||||
let o = &mut *ptr;
|
||||
let slice = ::std::slice::from_raw_parts(s as *const u8, to_usize(len));
|
||||
o.set_bytearray(to_usize(row), slice)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_f32(ptr: *const List, row: c_int) -> f32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_f32(ptr: *const List, row: c_int) -> f32 {
|
||||
let o = &*ptr;
|
||||
o.f32(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -336,8 +335,8 @@ pub unsafe extern "C" fn list_set_data_f32(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_f64(ptr: *const List, row: c_int) -> f64 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_f64(ptr: *const List, row: c_int) -> f64 {
|
||||
let o = &*ptr;
|
||||
o.f64(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -350,8 +349,8 @@ pub unsafe extern "C" fn list_set_data_f64(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_i16(ptr: *const List, row: c_int) -> i16 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_i16(ptr: *const List, row: c_int) -> i16 {
|
||||
let o = &*ptr;
|
||||
o.i16(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -364,8 +363,8 @@ pub unsafe extern "C" fn list_set_data_i16(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_i32(ptr: *const List, row: c_int) -> i32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_i32(ptr: *const List, row: c_int) -> i32 {
|
||||
let o = &*ptr;
|
||||
o.i32(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -378,8 +377,8 @@ pub unsafe extern "C" fn list_set_data_i32(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_i64(ptr: *const List, row: c_int) -> i64 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_i64(ptr: *const List, row: c_int) -> i64 {
|
||||
let o = &*ptr;
|
||||
o.i64(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -392,8 +391,8 @@ pub unsafe extern "C" fn list_set_data_i64(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_i8(ptr: *const List, row: c_int) -> i8 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_i8(ptr: *const List, row: c_int) -> i8 {
|
||||
let o = &*ptr;
|
||||
o.i8(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -406,8 +405,8 @@ pub unsafe extern "C" fn list_set_data_i8(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_optional_boolean(ptr: *const List, row: c_int) -> COption<bool> {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_optional_boolean(ptr: *const List, row: c_int) -> COption<bool> {
|
||||
let o = &*ptr;
|
||||
o.optional_boolean(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -425,12 +424,12 @@ pub unsafe extern "C" fn list_set_data_optional_boolean_none(ptr: *mut List, row
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_optional_bytearray(
|
||||
pub unsafe extern "C" fn list_data_optional_bytearray(
|
||||
ptr: *const List, row: c_int,
|
||||
d: *mut QByteArray,
|
||||
set: fn(*mut QByteArray, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.optional_bytearray(to_usize(row));
|
||||
if let Some(data) = data {
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
|
@ -439,12 +438,12 @@ pub extern "C" fn list_data_optional_bytearray(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_set_data_optional_bytearray(
|
||||
pub unsafe extern "C" fn list_set_data_optional_bytearray(
|
||||
ptr: *mut List, row: c_int,
|
||||
s: *const c_char, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let slice = unsafe { ::std::slice::from_raw_parts(s as *const u8, to_usize(len)) };
|
||||
let o = &mut *ptr;
|
||||
let slice = ::std::slice::from_raw_parts(s as *const u8, to_usize(len));
|
||||
o.set_optional_bytearray(to_usize(row), Some(slice))
|
||||
}
|
||||
|
||||
|
@ -454,12 +453,12 @@ pub unsafe extern "C" fn list_set_data_optional_bytearray_none(ptr: *mut List, r
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_optional_string(
|
||||
pub unsafe extern "C" fn list_data_optional_string(
|
||||
ptr: *const List, row: c_int,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.optional_string(to_usize(row));
|
||||
if let Some(data) = data {
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
|
@ -468,11 +467,11 @@ pub extern "C" fn list_data_optional_string(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_set_data_optional_string(
|
||||
pub unsafe extern "C" fn list_set_data_optional_string(
|
||||
ptr: *mut List, row: c_int,
|
||||
s: *const c_ushort, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let o = &mut *ptr;
|
||||
let mut v = String::new();
|
||||
set_string_from_utf16(&mut v, s, len);
|
||||
o.set_optional_string(to_usize(row), Some(v))
|
||||
|
@ -484,31 +483,31 @@ pub unsafe extern "C" fn list_set_data_optional_string_none(ptr: *mut List, row:
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_string(
|
||||
pub unsafe extern "C" fn list_data_string(
|
||||
ptr: *const List, row: c_int,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.string(to_usize(row));
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_set_data_string(
|
||||
pub unsafe extern "C" fn list_set_data_string(
|
||||
ptr: *mut List, row: c_int,
|
||||
s: *const c_ushort, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let o = &mut *ptr;
|
||||
let mut v = String::new();
|
||||
set_string_from_utf16(&mut v, s, len);
|
||||
o.set_string(to_usize(row), v)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_u16(ptr: *const List, row: c_int) -> u16 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_u16(ptr: *const List, row: c_int) -> u16 {
|
||||
let o = &*ptr;
|
||||
o.u16(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -521,8 +520,8 @@ pub unsafe extern "C" fn list_set_data_u16(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_u32(ptr: *const List, row: c_int) -> u32 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_u32(ptr: *const List, row: c_int) -> u32 {
|
||||
let o = &*ptr;
|
||||
o.u32(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -535,8 +534,8 @@ pub unsafe extern "C" fn list_set_data_u32(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_u64(ptr: *const List, row: c_int) -> u64 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_u64(ptr: *const List, row: c_int) -> u64 {
|
||||
let o = &*ptr;
|
||||
o.u64(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
@ -549,8 +548,8 @@ pub unsafe extern "C" fn list_set_data_u64(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn list_data_u8(ptr: *const List, row: c_int) -> u8 {
|
||||
let o = unsafe { &*ptr };
|
||||
pub unsafe extern "C" fn list_data_u8(ptr: *const List, row: c_int) -> u8 {
|
||||
let o = &*ptr;
|
||||
o.u8(to_usize(row)).into()
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
@ -88,20 +87,20 @@ pub unsafe extern "C" fn person_free(ptr: *mut Person) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_user_name_get(
|
||||
pub unsafe extern "C" fn person_user_name_get(
|
||||
ptr: *const Person,
|
||||
p: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.user_name();
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
set(p, s, to_c_int(v.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn person_user_name_set(ptr: *mut Person, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn person_user_name_set(ptr: *mut Person, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_user_name(s);
|
||||
|
|
|
@ -53,7 +53,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
@ -324,21 +323,21 @@ pub unsafe extern "C" fn object_boolean_set(ptr: *mut Object, v: bool) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_bytearray_get(
|
||||
pub unsafe extern "C" fn object_bytearray_get(
|
||||
ptr: *const Object,
|
||||
p: *mut QByteArray,
|
||||
set: fn(*mut QByteArray, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.bytearray();
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
set(p, s, to_c_int(v.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_bytearray_set(ptr: *mut Object, v: *const c_char, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let v = unsafe { slice::from_raw_parts(v as *const u8, to_usize(len)) };
|
||||
pub unsafe extern "C" fn object_bytearray_set(ptr: *mut Object, v: *const c_char, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let v = slice::from_raw_parts(v as *const u8, to_usize(len));
|
||||
o.set_bytearray(v);
|
||||
}
|
||||
|
||||
|
@ -416,18 +415,18 @@ pub unsafe extern "C" fn object_optional_boolean_set(ptr: *mut Object, v: bool)
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_optional_boolean_set_none(ptr: *mut Object) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn object_optional_boolean_set_none(ptr: *mut Object) {
|
||||
let o = &mut *ptr;
|
||||
o.set_optional_boolean(None);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_optional_bytearray_get(
|
||||
pub unsafe extern "C" fn object_optional_bytearray_get(
|
||||
ptr: *const Object,
|
||||
p: *mut QByteArray,
|
||||
set: fn(*mut QByteArray, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.optional_bytearray();
|
||||
if let Some(v) = v {
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
|
@ -436,25 +435,25 @@ pub extern "C" fn object_optional_bytearray_get(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_optional_bytearray_set(ptr: *mut Object, v: *const c_char, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let v = unsafe { slice::from_raw_parts(v as *const u8, to_usize(len)) };
|
||||
pub unsafe extern "C" fn object_optional_bytearray_set(ptr: *mut Object, v: *const c_char, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let v = slice::from_raw_parts(v as *const u8, to_usize(len));
|
||||
o.set_optional_bytearray(Some(v.into()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_optional_bytearray_set_none(ptr: *mut Object) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn object_optional_bytearray_set_none(ptr: *mut Object) {
|
||||
let o = &mut *ptr;
|
||||
o.set_optional_bytearray(None);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_optional_string_get(
|
||||
pub unsafe extern "C" fn object_optional_string_get(
|
||||
ptr: *const Object,
|
||||
p: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.optional_string();
|
||||
if let Some(v) = v {
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
|
@ -463,16 +462,16 @@ pub extern "C" fn object_optional_string_get(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_optional_string_set(ptr: *mut Object, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn object_optional_string_set(ptr: *mut Object, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_optional_string(Some(s));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_optional_string_set_none(ptr: *mut Object) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn object_optional_string_set_none(ptr: *mut Object) {
|
||||
let o = &mut *ptr;
|
||||
o.set_optional_string(None);
|
||||
}
|
||||
|
||||
|
@ -490,38 +489,38 @@ pub unsafe extern "C" fn object_optional_u64_set(ptr: *mut Object, v: u64) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_optional_u64_set_none(ptr: *mut Object) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn object_optional_u64_set_none(ptr: *mut Object) {
|
||||
let o = &mut *ptr;
|
||||
o.set_optional_u64(None);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_string_get(
|
||||
pub unsafe extern "C" fn object_string_get(
|
||||
ptr: *const Object,
|
||||
p: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.string();
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
set(p, s, to_c_int(v.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_string_set(ptr: *mut Object, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn object_string_set(ptr: *mut Object, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_string(s);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_string_by_function_get(
|
||||
pub unsafe extern "C" fn object_string_by_function_get(
|
||||
ptr: *const Object,
|
||||
p: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
o.string_by_function(|v| {
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
set(p, s, to_c_int(v.len()));
|
||||
|
@ -529,8 +528,8 @@ pub extern "C" fn object_string_by_function_get(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn object_string_by_function_set(ptr: *mut Object, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn object_string_by_function_set(ptr: *mut Object, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_string_by_function(s);
|
||||
|
|
|
@ -16,7 +16,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
@ -146,20 +145,20 @@ pub unsafe extern "C" fn inner_object_free(ptr: *mut InnerObject) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn inner_object_description_get(
|
||||
pub unsafe extern "C" fn inner_object_description_get(
|
||||
ptr: *const InnerObject,
|
||||
p: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let v = o.description();
|
||||
let s: *const c_char = v.as_ptr() as (*const c_char);
|
||||
set(p, s, to_c_int(v.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn inner_object_description_set(ptr: *mut InnerObject, v: *const c_ushort, len: c_int) {
|
||||
let o = unsafe { &mut *ptr };
|
||||
pub unsafe extern "C" fn inner_object_description_set(ptr: *mut InnerObject, v: *const c_ushort, len: c_int) {
|
||||
let o = &mut *ptr;
|
||||
let mut s = String::new();
|
||||
set_string_from_utf16(&mut s, v, len);
|
||||
o.set_description(s);
|
||||
|
|
|
@ -53,7 +53,6 @@ pub enum QString {}
|
|||
fn set_string_from_utf16(s: &mut String, str: *const c_ushort, len: c_int) {
|
||||
let utf16 = unsafe { slice::from_raw_parts(str, to_usize(len)) };
|
||||
let characters = decode_utf16(utf16.iter().cloned())
|
||||
.into_iter()
|
||||
.map(|r| r.unwrap());
|
||||
s.clear();
|
||||
s.extend(characters);
|
||||
|
@ -287,23 +286,23 @@ pub unsafe extern "C" fn persons_row(ptr: *const Persons, index: usize) -> c_int
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn persons_data_user_name(
|
||||
pub unsafe extern "C" fn persons_data_user_name(
|
||||
ptr: *const Persons, index: usize,
|
||||
d: *mut QString,
|
||||
set: fn(*mut QString, *const c_char, len: c_int),
|
||||
) {
|
||||
let o = unsafe { &*ptr };
|
||||
let o = &*ptr;
|
||||
let data = o.user_name(index);
|
||||
let s: *const c_char = data.as_ptr() as (*const c_char);
|
||||
set(d, s, to_c_int(data.len()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn persons_set_data_user_name(
|
||||
pub unsafe extern "C" fn persons_set_data_user_name(
|
||||
ptr: *mut Persons, index: usize,
|
||||
s: *const c_ushort, len: c_int,
|
||||
) -> bool {
|
||||
let o = unsafe { &mut *ptr };
|
||||
let o = &mut *ptr;
|
||||
let mut v = String::new();
|
||||
set_string_from_utf16(&mut v, s, len);
|
||||
o.set_user_name(index, v)
|
||||
|
|
Loading…
Reference in New Issue