phlow_ffi/
phlow_view_method.rs

1use phlow::PhlowViewMethod;
2use string_box::StringBox;
3use value_box::{ReturnBoxerResult, ValueBox, ValueBoxPointer};
4
5#[no_mangle]
6pub extern "C" fn phlow_view_method_get_full_name(
7    phlow_method: *mut ValueBox<PhlowViewMethod>,
8    full_name: *mut ValueBox<StringBox>,
9) {
10    phlow_method
11        .with_ref(|phlow_method| {
12            full_name.with_mut_ok(|full_name| {
13                full_name.set_string(phlow_method.full_method_name.clone())
14            })
15        })
16        .log();
17}
18
19#[no_mangle]
20pub extern "C" fn phlow_view_method_get_name(
21    phlow_method: *mut ValueBox<PhlowViewMethod>,
22    name: *mut ValueBox<StringBox>,
23) {
24    phlow_method
25        .with_ref(|phlow_method| {
26            name.with_mut_ok(|name| name.set_string(phlow_method.method_name.clone()))
27        })
28        .log();
29}
30
31#[no_mangle]
32pub extern "C" fn phlow_view_method_drop(phlow_method: *mut ValueBox<PhlowViewMethod>) {
33    phlow_method.release();
34}
35
36#[no_mangle]
37pub extern "C" fn phlow_view_methods_pop(
38    phlow_methods: *mut ValueBox<Vec<PhlowViewMethod>>,
39) -> *mut ValueBox<PhlowViewMethod> {
40    phlow_methods
41        .with_mut_ok(|phlow_methods| phlow_methods.pop())
42        .map(|method| {
43            method.map_or(std::ptr::null_mut(), |method| {
44                ValueBox::new(method).into_raw()
45            })
46        })
47        .or_log(std::ptr::null_mut())
48}
49
50#[no_mangle]
51pub extern "C" fn phlow_view_methods_drop(phlow_methods: *mut ValueBox<Vec<PhlowViewMethod>>) {
52    phlow_methods.release();
53}